From 8e6a3fbdf72562e45e84c3a67a7c09800ed7b6fe Mon Sep 17 00:00:00 2001 From: Chris Granade Date: Tue, 16 Mar 2021 16:42:19 -0700 Subject: [PATCH 01/32] Implement quantumlibraries#413. (#564) * Implement quantumlibraries#413. * Add missing open statement. * Fix build warnings. * Addressing feedback. --- .../Diagnostics/AssertAllZero.qs | 5 +- .../QSharpFoundation/Diagnostics/Facts.qs | 24 ++++ .../QSharpFoundation/Math/FloatingPoint.qs | 116 ++++++++++++++++++ .../TestProjects/IntrinsicTests/Math/Tests.qs | 35 ++++++ 4 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 src/Simulation/QSharpFoundation/Math/FloatingPoint.qs diff --git a/src/Simulation/QSharpFoundation/Diagnostics/AssertAllZero.qs b/src/Simulation/QSharpFoundation/Diagnostics/AssertAllZero.qs index 52470a92f13..e9ab9120a34 100644 --- a/src/Simulation/QSharpFoundation/Diagnostics/AssertAllZero.qs +++ b/src/Simulation/QSharpFoundation/Diagnostics/AssertAllZero.qs @@ -16,7 +16,7 @@ namespace Microsoft.Quantum.Diagnostics { /// - AssertQubit operation AssertAllZero (qubits : Qubit[]) : Unit { body (...) { - for (qubit in qubits) { + for qubit in qubits { AssertQubit(Zero, qubit); } } @@ -40,9 +40,8 @@ namespace Microsoft.Quantum.Diagnostics { /// # See Also /// - AssertQubitWithinTolerance operation AssertAllZeroWithinTolerance(qubits : Qubit[], tolerance : Double) : Unit { - body (...) { - for (qubit in qubits) { + for qubit in qubits { AssertQubitWithinTolerance(Zero, qubit, tolerance); } } diff --git a/src/Simulation/QSharpFoundation/Diagnostics/Facts.qs b/src/Simulation/QSharpFoundation/Diagnostics/Facts.qs index df3e8ebe383..e2c9ddca222 100644 --- a/src/Simulation/QSharpFoundation/Diagnostics/Facts.qs +++ b/src/Simulation/QSharpFoundation/Diagnostics/Facts.qs @@ -2,6 +2,7 @@ // Licensed under the MIT License. namespace Microsoft.Quantum.Diagnostics { + open Microsoft.Quantum.Math; /// # Summary /// Declares that a classical condition is true. @@ -48,4 +49,27 @@ namespace Microsoft.Quantum.Diagnostics { if (actual) { fail message; } } + /// # Summary + /// Declares that a given floating-point value represents a finite + /// number, failing when this is not the case. + /// + /// # Input + /// ## d + /// The floating-point value that is to be checked. + /// ## message + /// Failure message to be printed in the case that `d` is either + /// not finite, or not a number. + /// + /// # Example + /// The following Q# code will fail when run: + /// ```qsharp + /// FiniteFact(NaN(), "NaN is not a finite number."); + /// ``` + /// + /// # See Also + /// - Microsoft.Quantum.Diagnostics.Fact + function FiniteFact(d : Double, message : String) : Unit { + Fact(IsFinite(d), message); + } + } diff --git a/src/Simulation/QSharpFoundation/Math/FloatingPoint.qs b/src/Simulation/QSharpFoundation/Math/FloatingPoint.qs new file mode 100644 index 00000000000..6fd67cca089 --- /dev/null +++ b/src/Simulation/QSharpFoundation/Math/FloatingPoint.qs @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Math { + + /// # Summary + /// Returns a value that is not a number (i.e. NaN). + /// + /// # Ouputs + /// A double-precision floating point value that is not a number. + /// + /// # Remarks + /// The value output by this function follows IEEE 754 rules for how `NaN` + /// works when used with other double-precision floating point values. + /// For example, for any value `x` of type `Double`, `NaN() == x` is + /// `false`; this holds even if `x` is also `NaN()`. + /// + /// # See Also + /// - Microsoft.Quantum.Math.IsNaN + /// - Microsoft.Quantum.Math.IsInfinite + /// - Microsoft.Quantum.Math.IsFinite + function NaN() : Double { + return 0.0 / 0.0; + } + + /// # Summary + /// Returns whether a given floating-point value is not a number (i.e. + /// is NaN). + /// + /// # Input + /// ## d + /// A floating-point value to be checked. + /// + /// # Output + /// `true` if and only if `d` is not a number. + /// + /// # Remarks + /// Since `NaN()` is the only floating-point value that does not equal + /// itself, this function should be used instead of checking conditions such + /// as `d == NaN()`. + /// + /// # See Also + /// - Microsoft.Quantum.Math.NaN + /// - Microsoft.Quantum.Math.IsInfinite + /// - Microsoft.Quantum.Math.IsFinite + function IsNaN(d : Double) : Bool { + return d != d; + } + + /// # Summary + /// Returns whether a given floating-point value is either positive or + /// negative infinity. + /// + /// # Input + /// ## d + /// The floating-point value to be checked. + /// + /// # Ouput + /// `true` if and only if `d` is either positive or negative infinity. + /// + /// # Remarks + /// `NaN()` is not a number, and is thus neither a finite number nor + /// is it infinite. As such, both `IsInfinite(NaN())` and `IsFinite(NaN())` + /// return `false`. To check a value against `NaN()`, use `IsNaN(d)`. + /// + /// + /// Note that even though this function returns `true` for both + /// positive and negative infinities, these values can still be + /// discriminated by checking `d > 0.0` and `d < 0.0`. + /// + /// # Example + /// ```qsharp + /// Message($"{IsInfinite(42.0)}"); // false + /// Message($"{IsInfinite(NaN())}"); // false + /// Message($"{IsInfinite(-1.0 / 0.0}"); // true + /// + /// # See Also + /// - Microsoft.Quantum.Math.NaN + /// - Microsoft.Quantum.Math.IsNaN + /// - Microsoft.Quantum.Math.IsFinite + /// ``` + function IsInfinite(d : Double) : Bool { + return d == 1.0 / 0.0 or d == -1.0 / 0.0; + } + + /// # Summary + /// Returns whether a given floating-point value is a finite number. + /// + /// # Input + /// ## d + /// The floating-point value to be checked. + /// + /// # Ouput + /// `true` if and only if `d` is a finite number (i.e.: is neither infinite + /// nor NaN). + /// + /// # Remarks + /// `NaN()` is not a number, and is thus neither a finite number nor + /// is it infinite. As such, both `IsInfinite(NaN())` and `IsFinite(NaN())` + /// return `false`. To check a value against `NaN()`, use `IsNaN(d)`. + /// + /// # Example + /// ```qsharp + /// Message($"{IsFinite(42.0)}"); // true + /// Message($"{IsFinite(NaN())}"); // false + /// Message($"{IsFinite(-1.0 / 0.0)}"); // false + /// + /// # See Also + /// - Microsoft.Quantum.Math.NaN + /// - Microsoft.Quantum.Math.IsNaN + /// - Microsoft.Quantum.Math.IsInfinite + /// ``` + function IsFinite(d : Double) : Bool { + return not IsInfinite(d) and not IsNaN(d); + } +} diff --git a/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/Math/Tests.qs b/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/Math/Tests.qs index e9ab0883dbe..f252b3f0309 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/Math/Tests.qs +++ b/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/Math/Tests.qs @@ -84,4 +84,39 @@ namespace Microsoft.Quantum.Tests { EqualityFactL(ModPowL(8675309L, 5792L, 2345678L), 1936199L, "ModPowL(8675309L, 5792L, 2345678L) was incorrect."); } + @Test("QuantumSimulator") + function NaNIsNotEqualToAnything() : Unit { + Contradiction(NaN() == NaN(), "NaN should not equal NaN."); + Contradiction(NaN() == 42.0, "NaN should not equal any finite number."); + Contradiction(NaN() == 1.0 / 0.0, "NaN should not equal any infinite value."); + } + + @Test("QuantumSimulator") + function NaNIsNaN() : Unit { + Fact(IsNaN(NaN()), "NaN was not NaN."); + Contradiction(IsNaN(42.0), "42.0 should not be NaN."); + Contradiction(IsNaN(1.0 / 0.0), "+∞ should not be NaN."); + } + + @Test("QuantumSimulator") + function InfinityIsInfinite() : Unit { + Contradiction(IsInfinite(NaN()), "NaN should not be infinite."); + Contradiction(IsInfinite(42.0), "42.0 should not be infinite."); + Fact(IsInfinite(1.0 / 0.0), "+∞ should be infinite."); + Fact(IsInfinite(-1.0 / 0.0), "-∞ should be infinite."); + } + + @Test("QuantumSimulator") + function FiniteNumbersAreFinite() : Unit { + Contradiction(IsFinite(NaN()), "NaN should not be finite."); + Fact(IsFinite(42.0), "42.0 should be finite."); + Contradiction(IsFinite(1.0 / 0.0), "+∞ should not be finite."); + Contradiction(IsFinite(-1.0 / 0.0), "-∞ should not be finite."); + } + + @Test("QuantumSimulator") + function FiniteFactIsCorrect() : Unit { + FiniteFact(42.0, "42.0 should be finite."); + } + } From dcc498282f4565770bb4eaccd366e5fca92c5b25 Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Tue, 16 Mar 2021 18:43:01 -0700 Subject: [PATCH 02/32] Turn on QirRuntime build/validation by default (#566) * Turn on QirRuntime build/validation by default * Update package versions, remove redundant main * install prereqs by default too * Correctly throw when QIR build/test fails. * Update tests for latest QIR compiler features * Dont gate QIR tests on fullstate simulator flag * Use solution build to generate QIR --- AdvantageBenchmark/privateBuild/host.csproj | 2 +- .../releasedBuild/quantum/quantum.csproj | 2 +- Simulation.sln | 32 ++++++++++++++++++- build/build.ps1 | 2 +- build/ci.yml | 1 - build/prerequisites.ps1 | 12 ++----- build/test.ps1 | 2 +- src/QirRuntime/build-qir-runtime.ps1 | 28 +++++++++++----- src/QirRuntime/prerequisites.ps1 | 2 +- .../qir-standalone-input-reference.csproj | 2 +- src/QirRuntime/test-qir-runtime.ps1 | 6 ++++ src/QirRuntime/test/QIR-static/qir-driver.cpp | 14 +++++--- src/QirRuntime/test/QIR-static/qsharp/main.cs | 13 -------- .../test/QIR-static/qsharp/qir-gen.csproj | 3 +- .../test/QIR-tracer/qir-tracer-driver.cpp | 4 +-- .../Microsoft.Quantum.CSharpGeneration.fsproj | 2 +- ....Simulation.QCTraceSimulatorRuntime.csproj | 2 +- .../Microsoft.Quantum.QSharp.Core.csproj | 2 +- ...Microsoft.Quantum.QSharp.Foundation.csproj | 2 +- .../HoneywellExe/HoneywellExe.csproj | 2 +- .../IntrinsicTests/IntrinsicTests.csproj | 2 +- .../TestProjects/IonQExe/IonQExe.csproj | 2 +- .../Library with Spaces.csproj | 2 +- .../TestProjects/Library1/Library1.csproj | 2 +- .../TestProjects/Library2/Library2.csproj | 2 +- .../TestProjects/QCIExe/QCIExe.csproj | 2 +- .../TestProjects/QSharpExe/QSharpExe.csproj | 2 +- .../TargetedExe/TargetedExe.csproj | 2 +- .../TestProjects/UnitTests/UnitTests.csproj | 2 +- .../Tests.Microsoft.Quantum.Simulators.csproj | 2 +- ....Microsoft.Quantum.Simulators.Type1.csproj | 2 +- ....Microsoft.Quantum.Simulators.Type2.csproj | 2 +- ....Microsoft.Quantum.Simulators.Type3.csproj | 2 +- .../Microsoft.Quantum.Simulators.csproj | 2 +- .../Microsoft.Quantum.Type1.Core.csproj | 2 +- .../Microsoft.Quantum.Type2.Core.csproj | 2 +- .../Microsoft.Quantum.Type3.Core.csproj | 2 +- 37 files changed, 100 insertions(+), 69 deletions(-) delete mode 100644 src/QirRuntime/test/QIR-static/qsharp/main.cs diff --git a/AdvantageBenchmark/privateBuild/host.csproj b/AdvantageBenchmark/privateBuild/host.csproj index 422cd590f67..945a912657b 100644 --- a/AdvantageBenchmark/privateBuild/host.csproj +++ b/AdvantageBenchmark/privateBuild/host.csproj @@ -1,4 +1,4 @@ - + diff --git a/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj b/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj index 50c82fa9032..edc2bedc0fb 100644 --- a/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj +++ b/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj @@ -1,4 +1,4 @@ - + diff --git a/Simulation.sln b/Simulation.sln index b13975b999a..d141c8b46c7 100644 --- a/Simulation.sln +++ b/Simulation.sln @@ -85,6 +85,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Type3.Cor EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Microsoft.Quantum.Simulators.Type3", "src\Simulation\Simulators.Type3.Tests\Tests.Microsoft.Quantum.Simulators.Type3.csproj", "{7F80466B-A6B5-4EF1-A9E9-22ABAE3C20C1}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A6394A39-9862-4D5C-8FA1-81B61B424EE6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "QirRuntime", "QirRuntime", "{223F1FAE-5551-4237-AE8A-73502B007003}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E9FC86D7-DBE1-44B8-BF7F-61109E1AFE86}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "QIR-static", "QIR-static", "{9BED35A6-3FBF-4A55-8424-C801BEB64D68}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "qir-gen", "src\QirRuntime\test\QIR-static\qsharp\qir-gen.csproj", "{DC69B7C8-7B25-4C12-878A-DF59722C306E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -641,6 +651,22 @@ Global {7F80466B-A6B5-4EF1-A9E9-22ABAE3C20C1}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU {7F80466B-A6B5-4EF1-A9E9-22ABAE3C20C1}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU {7F80466B-A6B5-4EF1-A9E9-22ABAE3C20C1}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Debug|x64.ActiveCfg = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Debug|x64.Build.0 = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Release|Any CPU.Build.0 = Release|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Release|x64.ActiveCfg = Release|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.Release|x64.Build.0 = Release|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {DC69B7C8-7B25-4C12-878A-DF59722C306E}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -681,8 +707,12 @@ Global {789C86D9-CE77-40DA-BDDD-979436952512} = {93409CC3-8DF9-45FA-AE21-16A19FDEF650} {7E24885B-D86D-477E-A840-06FA53C33FE1} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} {7F80466B-A6B5-4EF1-A9E9-22ABAE3C20C1} = {34D419E9-CCF1-4E48-9FA4-3AD4B86BEEB4} + {223F1FAE-5551-4237-AE8A-73502B007003} = {A6394A39-9862-4D5C-8FA1-81B61B424EE6} + {E9FC86D7-DBE1-44B8-BF7F-61109E1AFE86} = {223F1FAE-5551-4237-AE8A-73502B007003} + {9BED35A6-3FBF-4A55-8424-C801BEB64D68} = {E9FC86D7-DBE1-44B8-BF7F-61109E1AFE86} + {DC69B7C8-7B25-4C12-878A-DF59722C306E} = {9BED35A6-3FBF-4A55-8424-C801BEB64D68} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {929C0464-86D8-4F70-8835-0A5EAF930821} EndGlobalSection -EndGlobal \ No newline at end of file +EndGlobal diff --git a/build/build.ps1 b/build/build.ps1 index 9ff2e82b758..d1afe280967 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -45,7 +45,7 @@ Build-One 'publish' '../src/Simulation/CSharpGeneration.App' Build-One 'build' '../Simulation.sln' -if ($Env:ENABLE_QIRRUNTIME -eq "true") { +if ($Env:ENABLE_QIRRUNTIME -ne "false") { $qirRuntime = (Join-Path $PSScriptRoot "../src/QirRuntime") & "$qirRuntime/build-qir-runtime.ps1" if ($LastExitCode -ne 0) { diff --git a/build/ci.yml b/build/ci.yml index 111b68c0595..34383b7c24f 100644 --- a/build/ci.yml +++ b/build/ci.yml @@ -22,7 +22,6 @@ variables: Drops.Dir: $(Build.ArtifactStagingDirectory)/drops Drop.Native: $(System.DefaultWorkingDirectory)/xplat CI: "true" - ENABLE_QIRRUNTIME: "false" jobs: - job: build diff --git a/build/prerequisites.ps1 b/build/prerequisites.ps1 index 2d745543ecf..32259ba09ce 100644 --- a/build/prerequisites.ps1 +++ b/build/prerequisites.ps1 @@ -21,12 +21,6 @@ if ($Env:ENABLE_NATIVE -ne "false") { Write-Host "Skipping installing prerequisites for native simulator because ENABLE_NATIVE variable set to: $Env:ENABLE_NATIVE" } -# At the moment the QIR Runtime build isn't enabled locally by default. -if ($Env:ENABLE_QIRRUNTIME -eq "true") { - Push-Location (Join-Path $PSScriptRoot "../src/QirRuntime") - .\prerequisites.ps1 - Pop-Location -} else { - Write-Host "Skipping installing prerequisites for qir runtime because ENABLE_QIRRUNTIME variable set to: $Env:ENABLE_QIRRUNTIME" -} - +Push-Location (Join-Path $PSScriptRoot "../src/QirRuntime") + .\prerequisites.ps1 +Pop-Location diff --git a/build/test.ps1 b/build/test.ps1 index cc2e0507a28..0de3665976e 100644 --- a/build/test.ps1 +++ b/build/test.ps1 @@ -37,7 +37,7 @@ function Test-One { Test-One '../Simulation.sln' -if (($Env:ENABLE_NATIVE -ne "false") -and ($Env:ENABLE_QIRRUNTIME -eq "true")) { +if ($Env:ENABLE_QIRRUNTIME -ne "false") { $qirRuntime = (Join-Path $PSScriptRoot "../src/QirRuntime") & "$qirRuntime/test-qir-runtime.ps1" if ($LastExitCode -ne 0) { diff --git a/src/QirRuntime/build-qir-runtime.ps1 b/src/QirRuntime/build-qir-runtime.ps1 index f7e4388b884..e10c3dde683 100644 --- a/src/QirRuntime/build-qir-runtime.ps1 +++ b/src/QirRuntime/build-qir-runtime.ps1 @@ -4,10 +4,13 @@ & (Join-Path $PSScriptRoot .. .. build set-env.ps1) Write-Host "##[info]Compile Q# Projects into QIR" $qirStaticPath = Join-Path $PSScriptRoot test QIR-static qsharp -dotnet build $qirStaticPath -c $Env:BUILD_CONFIGURATION -v $Env:BUILD_VERBOSITY -if ($LastExitCode -ne 0) { - Write-Host "##vso[task.logissue type=error;]Failed to compile Q# project at '$qirStaticPath' into QIR." - return +if (!(Test-Path (Join-Path $qirStaticPath qir *.ll))) { + Write-Host "##[info]Build Q# project for QIR tests" + dotnet build $qirStaticPath -c $Env:BUILD_CONFIGURATION -v $Env:BUILD_VERBOSITY + if ($LastExitCode -ne 0) { + Write-Host "##vso[task.logissue type=error;]Failed to compile Q# project at '$qirStaticPath' into QIR." + throw "Failed to compile Q# project at '$qirStaticPath' into QIR." + } } Copy-Item -Path (Join-Path $qirStaticPath qir *.ll) -Destination (Split-Path $qirStaticPath -Parent) # Also copy to drops so it ends up in build artifacts, for easier post-build debugging. @@ -59,15 +62,20 @@ if (-not (Test-Path $qirRuntimeBuildFolder)) { New-Item -Path $qirRuntimeBuildFolder -ItemType "directory" } +$all_ok = $true + Push-Location $qirRuntimeBuildFolder cmake -G Ninja $clangTidy -D CMAKE_BUILD_TYPE="$Env:BUILD_CONFIGURATION" ../.. if ($LastExitCode -ne 0) { Write-Host "##vso[task.logissue type=error;]Failed to generate QIR Runtime." -} -cmake --build . --target install -if ($LastExitCode -ne 0) { - Write-Host "##vso[task.logissue type=error;]Failed to build QIR Runtime." + $all_ok = $false +} else { + cmake --build . --target install + if ($LastExitCode -ne 0) { + Write-Host "##vso[task.logissue type=error;]Failed to build QIR Runtime." + $all_ok = $false + } } $os = "win" @@ -90,3 +98,7 @@ Pop-Location $env:CC = $oldCC $env:CXX = $oldCXX $env:RC = $oldRC + +if (-not $all_ok) { + throw "At least one project failed to compile. Check the logs." +} \ No newline at end of file diff --git a/src/QirRuntime/prerequisites.ps1 b/src/QirRuntime/prerequisites.ps1 index 17b9b0633ca..43a7337012f 100644 --- a/src/QirRuntime/prerequisites.ps1 +++ b/src/QirRuntime/prerequisites.ps1 @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -if ($Env:ENABLE_QIRRUNTIME -eq "true") { +if ($Env:ENABLE_QIRRUNTIME -ne "false") { if (($IsWindows) -or ((Test-Path Env:AGENT_OS) -and ($Env:AGENT_OS.StartsWith("Win"))) -and !(Get-Command clang -ErrorAction SilentlyContinue)) { choco install llvm diff --git a/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj b/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj index dc30ec6b33f..5878e9774c3 100644 --- a/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj +++ b/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/QirRuntime/test-qir-runtime.ps1 b/src/QirRuntime/test-qir-runtime.ps1 index 0b0094e1054..ecf02e60823 100644 --- a/src/QirRuntime/test-qir-runtime.ps1 +++ b/src/QirRuntime/test-qir-runtime.ps1 @@ -1,6 +1,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +$all_ok = $true + Write-Host "##[info]Test QIR Runtime" Push-Location (Join-Path $PSScriptRoot build $Env:BUILD_CONFIGURATION test) @@ -26,3 +28,7 @@ if ($LastExitCode -ne 0) { } Pop-Location + +if (-not $all_ok) { + throw "At least one project failed testing. Check the logs." +} diff --git a/src/QirRuntime/test/QIR-static/qir-driver.cpp b/src/QirRuntime/test/QIR-static/qir-driver.cpp index f0c34c84d5a..db166dba9e5 100644 --- a/src/QirRuntime/test/QIR-static/qir-driver.cpp +++ b/src/QirRuntime/test/QIR-static/qir-driver.cpp @@ -49,24 +49,28 @@ To update the *.ll files to a newer version: - the generated file name.ll will be placed into `s` folder */ +struct Array { + int64_t itemSize; + void* buffer; +}; + // The function replaces array[index] with value, then creates a new array that consists of every other element up to // index (starting from index backwards) and every element from index to the end. It returns the sum of elements in this // new array extern "C" int64_t Microsoft__Quantum__Testing__QIR__Test_Arrays( // NOLINT - int64_t count, - int64_t* array, + Array* array, int64_t index, int64_t val, bool compilerDecoy); TEST_CASE("QIR: Using 1D arrays", "[qir][qir.arr1d]") { - // re-enable tracking when https://github.com/microsoft/qsharp-compiler/issues/844 is fixed - QirContextScope qirctx(nullptr, false /*trackAllocatedObjects*/); + QirContextScope qirctx(nullptr, true /*trackAllocatedObjects*/); constexpr int64_t n = 5; int64_t values[n] = {0, 1, 2, 3, 4}; + auto array = Array{5, values}; - int64_t res = Microsoft__Quantum__Testing__QIR__Test_Arrays(n, values, 2, 42, false); + int64_t res = Microsoft__Quantum__Testing__QIR__Test_Arrays(&array, 2, 42, false); REQUIRE(res == (0 + 42) + (42 + 3 + 4)); } diff --git a/src/QirRuntime/test/QIR-static/qsharp/main.cs b/src/QirRuntime/test/QIR-static/qsharp/main.cs deleted file mode 100644 index 3e0cec7acae..00000000000 --- a/src/QirRuntime/test/QIR-static/qsharp/main.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -// Currently, compiling to QIR has to suppress C# generation but then we need to provide Main function ourselves. -namespace CompilerWorkaround -{ - class Program - { - static void Main(string[] args) - { - } - } -} \ No newline at end of file diff --git a/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj b/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj index 75a033a2193..071e4daa6d5 100644 --- a/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj +++ b/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj @@ -1,10 +1,9 @@ - + Exe netcoreapp3.1 True - false false diff --git a/src/QirRuntime/test/QIR-tracer/qir-tracer-driver.cpp b/src/QirRuntime/test/QIR-tracer/qir-tracer-driver.cpp index 09199fe5782..8d386eb976b 100644 --- a/src/QirRuntime/test/QIR-tracer/qir-tracer-driver.cpp +++ b/src/QirRuntime/test/QIR-tracer/qir-tracer-driver.cpp @@ -20,7 +20,7 @@ namespace TracerUser TEST_CASE("Invoke each intrinsic from Q# core once", "[qir-tracer]") { shared_ptr tr = CreateTracer(1 /*layer duration*/, g_operationNames); - QirContextScope qirctx(tr.get(), false /*trackAllocatedObjects*/); + QirContextScope qirctx(tr.get(), true /*trackAllocatedObjects*/); REQUIRE_NOTHROW(Microsoft__Quantum__Testing__Tracer__TestCoreIntrinsics__body()); const vector& layers = tr->UseLayers(); @@ -37,7 +37,7 @@ TEST_CASE("Invoke each intrinsic from Q# core once", "[qir-tracer]") TEST_CASE("Conditional execution on measurement result", "[qir-tracer]") { shared_ptr tr = CreateTracer(1 /*layer duration*/, g_operationNames); - QirContextScope qirctx(tr.get(), false /*trackAllocatedObjects*/); + QirContextScope qirctx(tr.get(), true /*trackAllocatedObjects*/); REQUIRE_NOTHROW(Microsoft__Quantum__Testing__Tracer__TestMeasurements__body()); diff --git a/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj b/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj index 2b666f6ee5d..dbcade9d0a4 100644 --- a/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj +++ b/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj @@ -22,7 +22,7 @@ - + diff --git a/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj b/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj index 4ddaacb5478..b9a9f23a05e 100644 --- a/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj +++ b/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj b/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj index 5a3259aaefe..55f5296116c 100644 --- a/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj +++ b/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj b/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj index 6e2ebc85e7f..5f2739dc51b 100644 --- a/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj +++ b/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj index 41d13f419bd..8d6648d99bd 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj b/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj index 1a751162446..5df0333fbfd 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.1 diff --git a/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj index 9dca549e624..155c413dd90 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj index 9ffe7425982..967fdc57f93 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 false diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj index 8d99e867492..3be0a69493f 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj index 8d99e867492..3be0a69493f 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 diff --git a/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj index 8befb110c86..10e31d76d29 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj index d807ca12f3d..46fffc1465e 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj index 926e3a698b3..efc6191b015 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj index f9bb1941fb3..6e8e0d10e34 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.1 diff --git a/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj b/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj index 74861b061e7..281a717746a 100644 --- a/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj +++ b/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj b/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj index e0e3f72e741..48eae1fd4aa 100644 --- a/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj +++ b/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj b/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj index a48ce4a0e54..4ecc2f5d180 100644 --- a/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj +++ b/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Type3.Tests/Tests.Microsoft.Quantum.Simulators.Type3.csproj b/src/Simulation/Simulators.Type3.Tests/Tests.Microsoft.Quantum.Simulators.Type3.csproj index a667973bb0f..4de9084ec8b 100644 --- a/src/Simulation/Simulators.Type3.Tests/Tests.Microsoft.Quantum.Simulators.Type3.csproj +++ b/src/Simulation/Simulators.Type3.Tests/Tests.Microsoft.Quantum.Simulators.Type3.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj index e16bde73d07..2704eb6a47c 100644 --- a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj +++ b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj b/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj index 5987caf0baa..f75c9ba8145 100644 --- a/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj +++ b/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj b/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj index 3cd88162088..804ad9d7054 100644 --- a/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj +++ b/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.csproj b/src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.csproj index 9e4252461a8..bfd3eee533e 100644 --- a/src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.csproj +++ b/src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.csproj @@ -1,4 +1,4 @@ - + From 47c32db5e36e84aa9142be7ec292857ffdeb8bea Mon Sep 17 00:00:00 2001 From: Robin Kuzmin Date: Thu, 18 Mar 2021 15:21:09 -0700 Subject: [PATCH 03/32] Fixed prerequisites.ps1 (#571) --- src/QirRuntime/prerequisites.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/QirRuntime/prerequisites.ps1 b/src/QirRuntime/prerequisites.ps1 index 43a7337012f..72ae1b5079c 100644 --- a/src/QirRuntime/prerequisites.ps1 +++ b/src/QirRuntime/prerequisites.ps1 @@ -2,10 +2,11 @@ # Licensed under the MIT License. if ($Env:ENABLE_QIRRUNTIME -ne "false") { - if (($IsWindows) -or ((Test-Path Env:AGENT_OS) -and ($Env:AGENT_OS.StartsWith("Win"))) -and - !(Get-Command clang -ErrorAction SilentlyContinue)) { - choco install llvm - choco install ninja + if (($IsWindows) -or ((Test-Path Env:AGENT_OS) -and ($Env:AGENT_OS.StartsWith("Win")))) { + if (!(Get-Command clang -ErrorAction SilentlyContinue)) { + choco install llvm + choco install ninja + } } elseif ($IsMacOS) { brew install ninja } else { From 1b726d6b41af86a50e544197dfa10858e8fea8f8 Mon Sep 17 00:00:00 2001 From: Robin Kuzmin Date: Thu, 18 Mar 2021 21:00:01 -0700 Subject: [PATCH 04/32] Runtime Changes to Match the Latest QIR Spec (#569) * Changed quantum__rt__heap_alloc() signature * Added quantum__rt_string_get_(data|length) * Changed the __quantum__rt__*_update_reference_count signature * Changed the __quantum__rt__string_create signature * Added to quantum__rt__qubit_release_array() the array release * Changed the __quantum__rt__.*_update_alias_count() signature * Added __quantum__rt__result_get_zero and a __quantum__rt__result_get_one * Added __quantum__rt__capture_update_reference_count and __quantum__rt__capture_update_alias_count * Added __quantum__rt__memory_allocate() * Update QIR scripts to latest compiler support Co-authored-by: Stefan J. Wernli --- AdvantageBenchmark/privateBuild/host.csproj | 2 +- .../releasedBuild/quantum/quantum.csproj | 2 +- Simulation.sln | 91 + src/QirRuntime/build-qir-runtime.ps1 | 36 +- src/QirRuntime/lib/QIR/arrays.cpp | 2 + src/QirRuntime/lib/QIR/bridge-rt.ll | 97 +- src/QirRuntime/lib/QIR/callables.cpp | 4 +- src/QirRuntime/lib/QIR/delegated.cpp | 4 +- src/QirRuntime/lib/QIR/strings.cpp | 11 + src/QirRuntime/lib/QIR/utils.cpp | 15 +- .../lib/QSharpFoundation/conditionals.cpp | 2 +- src/QirRuntime/public/QirRuntime.hpp | 23 +- src/QirRuntime/public/QirTypes.hpp | 6 +- .../qir-standalone-input-reference.ll | 77 - .../qir-standalone-input-reference.csproj | 6 +- src/QirRuntime/test-qir-runtime.ps1 | 1 + .../FullstateSimulator/qir-test-simulator.ll | 1398 ------------ .../qsharp/qir-test-simulator.csproj | 14 + .../{ => qsharp}/qir-test-simulator.qs | 37 +- .../test/QIR-dynamic/CMakeLists.txt | 12 +- .../test/QIR-dynamic/qir-test-random-lnx.ll | 142 -- .../test/QIR-dynamic/qir-test-random-win.ll | 142 -- .../QIR-dynamic/qsharp/qir-test-random.csproj | 14 + .../{ => qsharp}/qir-test-random.qs | 48 +- .../test/QIR-static/qir-test-noqsharp.ll | 6 +- .../test/QIR-static/qsharp/qir-gen.csproj | 2 +- src/QirRuntime/test/QIR-tracer/CMakeLists.txt | 12 +- .../{ => qsharp}/tracer-conditionals.qs | 48 +- .../QIR-tracer/{ => qsharp}/tracer-core.qs | 0 .../{ => qsharp}/tracer-intrinsics.qs | 0 .../test/QIR-tracer/qsharp/tracer-qir.csproj | 10 + .../QIR-tracer/{ => qsharp}/tracer-target.qs | 0 .../test/QIR-tracer/tracer-qir-lnx.ll | 2019 ----------------- .../test/QIR-tracer/tracer-qir-win.ll | 2019 ----------------- .../Microsoft.Quantum.CSharpGeneration.fsproj | 2 +- ....Simulation.QCTraceSimulatorRuntime.csproj | 2 +- .../Microsoft.Quantum.QSharp.Core.csproj | 2 +- ...Microsoft.Quantum.QSharp.Foundation.csproj | 2 +- .../HoneywellExe/HoneywellExe.csproj | 2 +- .../IntrinsicTests/IntrinsicTests.csproj | 2 +- .../TestProjects/IonQExe/IonQExe.csproj | 2 +- .../Library with Spaces.csproj | 2 +- .../TestProjects/Library1/Library1.csproj | 2 +- .../TestProjects/Library2/Library2.csproj | 2 +- .../TestProjects/QCIExe/QCIExe.csproj | 2 +- .../TestProjects/QSharpExe/QSharpExe.csproj | 2 +- .../TargetedExe/TargetedExe.csproj | 2 +- .../TestProjects/UnitTests/UnitTests.csproj | 2 +- .../Tests.Microsoft.Quantum.Simulators.csproj | 2 +- ....Microsoft.Quantum.Simulators.Type1.csproj | 2 +- ....Microsoft.Quantum.Simulators.Type2.csproj | 2 +- ....Microsoft.Quantum.Simulators.Type3.csproj | 2 +- .../Microsoft.Quantum.Simulators.csproj | 2 +- .../Microsoft.Quantum.Type1.Core.csproj | 2 +- .../Microsoft.Quantum.Type2.Core.csproj | 2 +- .../Microsoft.Quantum.Type3.Core.csproj | 2 +- 56 files changed, 385 insertions(+), 5961 deletions(-) delete mode 100644 src/QirRuntime/samples/StandaloneInputReference/qir-standalone-input-reference.ll delete mode 100644 src/QirRuntime/test/FullstateSimulator/qir-test-simulator.ll create mode 100644 src/QirRuntime/test/FullstateSimulator/qsharp/qir-test-simulator.csproj rename src/QirRuntime/test/FullstateSimulator/{ => qsharp}/qir-test-simulator.qs (67%) delete mode 100644 src/QirRuntime/test/QIR-dynamic/qir-test-random-lnx.ll delete mode 100644 src/QirRuntime/test/QIR-dynamic/qir-test-random-win.ll create mode 100644 src/QirRuntime/test/QIR-dynamic/qsharp/qir-test-random.csproj rename src/QirRuntime/test/QIR-dynamic/{ => qsharp}/qir-test-random.qs (96%) rename src/QirRuntime/test/QIR-tracer/{ => qsharp}/tracer-conditionals.qs (97%) rename src/QirRuntime/test/QIR-tracer/{ => qsharp}/tracer-core.qs (100%) rename src/QirRuntime/test/QIR-tracer/{ => qsharp}/tracer-intrinsics.qs (100%) create mode 100644 src/QirRuntime/test/QIR-tracer/qsharp/tracer-qir.csproj rename src/QirRuntime/test/QIR-tracer/{ => qsharp}/tracer-target.qs (100%) delete mode 100644 src/QirRuntime/test/QIR-tracer/tracer-qir-lnx.ll delete mode 100644 src/QirRuntime/test/QIR-tracer/tracer-qir-win.ll diff --git a/AdvantageBenchmark/privateBuild/host.csproj b/AdvantageBenchmark/privateBuild/host.csproj index 945a912657b..ab801ea9a88 100644 --- a/AdvantageBenchmark/privateBuild/host.csproj +++ b/AdvantageBenchmark/privateBuild/host.csproj @@ -1,4 +1,4 @@ - + diff --git a/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj b/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj index edc2bedc0fb..3b308dec968 100644 --- a/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj +++ b/AdvantageBenchmark/releasedBuild/quantum/quantum.csproj @@ -1,4 +1,4 @@ - + diff --git a/Simulation.sln b/Simulation.sln index d141c8b46c7..dc9f314bfcf 100644 --- a/Simulation.sln +++ b/Simulation.sln @@ -95,6 +95,24 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "QIR-static", "QIR-static", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "qir-gen", "src\QirRuntime\test\QIR-static\qsharp\qir-gen.csproj", "{DC69B7C8-7B25-4C12-878A-DF59722C306E}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FullstateSimulator", "FullstateSimulator", "{932E88FC-AB51-449D-937E-BB3050DF37C9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "qir-test-simulator", "src\QirRuntime\test\FullstateSimulator\qsharp\qir-test-simulator.csproj", "{D529DE2B-C65B-4B89-82F3-FF712BC832BC}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "QIR-dynamic", "QIR-dynamic", "{E0DE8EF7-A587-4D02-8813-B344365E5CF8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "qir-test-random", "src\QirRuntime\test\QIR-dynamic\qsharp\qir-test-random.csproj", "{9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "QIR-tracer", "QIR-tracer", "{99C04F12-B449-4832-BFD6-FE5E91BAE393}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tracer-qir", "src\QirRuntime\test\QIR-tracer\qsharp\tracer-qir.csproj", "{390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{306E9DC4-15F6-4D98-8846-34EBBBC45CB0}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "StandaloneInputReference", "StandaloneInputReference", "{700A1D87-D0DE-4621-A6CD-3DC0AA47D492}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "qir-standalone-input-reference", "src\QirRuntime\samples\StandaloneInputReference\qsharp\qir-standalone-input-reference.csproj", "{91DF2E6D-65C1-478E-A276-337A40ADB1FB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -667,6 +685,70 @@ Global {DC69B7C8-7B25-4C12-878A-DF59722C306E}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU {DC69B7C8-7B25-4C12-878A-DF59722C306E}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU {DC69B7C8-7B25-4C12-878A-DF59722C306E}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.Debug|x64.ActiveCfg = Debug|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.Debug|x64.Build.0 = Debug|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.Release|Any CPU.Build.0 = Release|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.Release|x64.ActiveCfg = Release|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.Release|x64.Build.0 = Release|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {D529DE2B-C65B-4B89-82F3-FF712BC832BC}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.Debug|x64.ActiveCfg = Debug|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.Debug|x64.Build.0 = Debug|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.Release|Any CPU.Build.0 = Release|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.Release|x64.ActiveCfg = Release|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.Release|x64.Build.0 = Release|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.Debug|x64.ActiveCfg = Debug|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.Debug|x64.Build.0 = Debug|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.Release|Any CPU.Build.0 = Release|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.Release|x64.ActiveCfg = Release|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.Release|x64.Build.0 = Release|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.Debug|x64.ActiveCfg = Debug|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.Debug|x64.Build.0 = Debug|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.MinSizeRel|x64.Build.0 = Debug|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.Release|Any CPU.Build.0 = Release|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.Release|x64.ActiveCfg = Release|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.Release|x64.Build.0 = Release|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.RelWithDebInfo|Any CPU.ActiveCfg = Debug|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.RelWithDebInfo|Any CPU.Build.0 = Debug|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.RelWithDebInfo|x64.ActiveCfg = Debug|Any CPU + {91DF2E6D-65C1-478E-A276-337A40ADB1FB}.RelWithDebInfo|x64.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -711,6 +793,15 @@ Global {E9FC86D7-DBE1-44B8-BF7F-61109E1AFE86} = {223F1FAE-5551-4237-AE8A-73502B007003} {9BED35A6-3FBF-4A55-8424-C801BEB64D68} = {E9FC86D7-DBE1-44B8-BF7F-61109E1AFE86} {DC69B7C8-7B25-4C12-878A-DF59722C306E} = {9BED35A6-3FBF-4A55-8424-C801BEB64D68} + {932E88FC-AB51-449D-937E-BB3050DF37C9} = {E9FC86D7-DBE1-44B8-BF7F-61109E1AFE86} + {D529DE2B-C65B-4B89-82F3-FF712BC832BC} = {932E88FC-AB51-449D-937E-BB3050DF37C9} + {E0DE8EF7-A587-4D02-8813-B344365E5CF8} = {E9FC86D7-DBE1-44B8-BF7F-61109E1AFE86} + {9FCFB543-A126-41DF-80A3-40A6AFBA4F4F} = {E0DE8EF7-A587-4D02-8813-B344365E5CF8} + {99C04F12-B449-4832-BFD6-FE5E91BAE393} = {E9FC86D7-DBE1-44B8-BF7F-61109E1AFE86} + {390608C0-35C4-4E81-8BF8-91F9EA9C1CDA} = {99C04F12-B449-4832-BFD6-FE5E91BAE393} + {306E9DC4-15F6-4D98-8846-34EBBBC45CB0} = {223F1FAE-5551-4237-AE8A-73502B007003} + {700A1D87-D0DE-4621-A6CD-3DC0AA47D492} = {306E9DC4-15F6-4D98-8846-34EBBBC45CB0} + {91DF2E6D-65C1-478E-A276-337A40ADB1FB} = {700A1D87-D0DE-4621-A6CD-3DC0AA47D492} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {929C0464-86D8-4F70-8835-0A5EAF930821} diff --git a/src/QirRuntime/build-qir-runtime.ps1 b/src/QirRuntime/build-qir-runtime.ps1 index e10c3dde683..c9ef084f33b 100644 --- a/src/QirRuntime/build-qir-runtime.ps1 +++ b/src/QirRuntime/build-qir-runtime.ps1 @@ -2,19 +2,33 @@ # Licensed under the MIT License. & (Join-Path $PSScriptRoot .. .. build set-env.ps1) -Write-Host "##[info]Compile Q# Projects into QIR" -$qirStaticPath = Join-Path $PSScriptRoot test QIR-static qsharp -if (!(Test-Path (Join-Path $qirStaticPath qir *.ll))) { - Write-Host "##[info]Build Q# project for QIR tests" - dotnet build $qirStaticPath -c $Env:BUILD_CONFIGURATION -v $Env:BUILD_VERBOSITY - if ($LastExitCode -ne 0) { - Write-Host "##vso[task.logissue type=error;]Failed to compile Q# project at '$qirStaticPath' into QIR." - throw "Failed to compile Q# project at '$qirStaticPath' into QIR." + +function Build-QirProject { + param ( + [string] + $FolderPath + ) + + if (!(Test-Path (Join-Path $FolderPath qir *.ll))) { + Write-Host "##[info]Build Q# project for QIR tests '$FolderPath'" + dotnet build $FolderPath -c $Env:BUILD_CONFIGURATION -v $Env:BUILD_VERBOSITY + if ($LastExitCode -ne 0) { + Write-Host "##vso[task.logissue type=error;]Failed to compile Q# project at '$FolderPath' into QIR." + throw "Failed to compile Q# project at '$FolderPath' into QIR." + } } + Copy-Item -Path (Join-Path $FolderPath qir *.ll) -Destination (Split-Path $FolderPath -Parent) + # Also copy to drops so it ends up in build artifacts, for easier post-build debugging. + Copy-Item -Path (Join-Path $FolderPath qir *.ll) -Destination $Env:DROPS_DIR } -Copy-Item -Path (Join-Path $qirStaticPath qir *.ll) -Destination (Split-Path $qirStaticPath -Parent) -# Also copy to drops so it ends up in build artifacts, for easier post-build debugging. -Copy-Item -Path (Join-Path $qirStaticPath qir *.ll) -Destination $Env:DROPS_DIR + +Write-Host "##[info]Compile Q# Projects into QIR" +Build-QirProject (Join-Path $PSScriptRoot test QIR-static qsharp) +Build-QirProject (Join-Path $PSScriptRoot test QIR-dynamic qsharp) +Build-QirProject (Join-Path $PSScriptRoot test QIR-tracer qsharp) +Build-QirProject (Join-Path $PSScriptRoot test FullstateSimulator qsharp) +Build-QirProject (Join-Path $PSScriptRoot samples StandaloneInputReference qsharp) + Write-Host "##[info]Build QIR Runtime" $oldCC = $env:CC diff --git a/src/QirRuntime/lib/QIR/arrays.cpp b/src/QirRuntime/lib/QIR/arrays.cpp index 00d8d9e19c6..54c68d08b82 100644 --- a/src/QirRuntime/lib/QIR/arrays.cpp +++ b/src/QirRuntime/lib/QIR/arrays.cpp @@ -231,6 +231,8 @@ extern "C" qa->ownsQubits = false; } + + quantum__rt__array_update_reference_count(qa, -1); } QirArray* quantum__rt__array_create_1d(int32_t itemSizeInBytes, int64_t count_items) diff --git a/src/QirRuntime/lib/QIR/bridge-rt.ll b/src/QirRuntime/lib/QIR/bridge-rt.ll index f27357e918c..950a26abf67 100644 --- a/src/QirRuntime/lib/QIR/bridge-rt.ll +++ b/src/QirRuntime/lib/QIR/bridge-rt.ll @@ -37,8 +37,9 @@ ;------------------------------------------------------------------------------ ; classical ; -declare i8* @quantum__rt__heap_alloc(i32) +declare i8* @quantum__rt__heap_alloc(i64) declare void @quantum__rt__heap_free(i8*) +declare i8* @quantum__rt__memory_allocate(i64) declare void @quantum__rt__fail(%"struct.QirString"*) ;------------------------------------------------------------------------------ @@ -48,6 +49,8 @@ declare %class.QUBIT* @quantum__rt__qubit_allocate() declare void @quantum__rt__qubit_release(%class.QUBIT*) declare i1 @quantum__rt__result_equal(%class.RESULT*, %class.RESULT*) declare void @quantum__rt__result_update_reference_count(%class.RESULT* %r, i32 %c) +declare %class.RESULT* @quantum__rt__result_get_zero() +declare %class.RESULT* @quantum__rt__result_get_one() ;------------------------------------------------------------------------------ ; arrays @@ -85,7 +88,7 @@ declare %"struct.QirCallable"* @quantum__rt__callable_copy(%"struct.QirCallable" declare %"struct.QirCallable"* @quantum__rt__callable_make_adjoint(%"struct.QirCallable"*) declare %"struct.QirCallable"* @quantum__rt__callable_make_controlled(%"struct.QirCallable"*) declare void @quantum__rt__callable_update_alias_count(%"struct.QirCallable"*, i32) -declare void @quantum__rt__callable_memory_management(i32, %"struct.QirCallable"*, i64) +declare void @quantum__rt__callable_memory_management(i32, %"struct.QirCallable"*, i32) ;------------------------------------------------------------------------------ ; strings @@ -101,6 +104,8 @@ declare %"struct.QirString"* @quantum__rt__result_to_string(%class.RESULT*) declare %"struct.QirString"* @quantum__rt__pauli_to_string(%PauliId) declare %"struct.QirString"* @quantum__rt__qubit_to_string(%class.QUBIT*) declare %"struct.QirString"* @quantum__rt__range_to_string(%"struct.QirRange"* dereferenceable(24) %range) +declare i8* @quantum__rt_string_get_data(%"struct.QirString"* %str) +declare i32 @quantum__rt_string_get_length(%"struct.QirString"* %str) @@ -111,8 +116,8 @@ declare %"struct.QirString"* @quantum__rt__range_to_string(%"struct.QirRange"* d ;------------------------------------------------------------------------------ ; classical bridge ; -define dllexport i8* @__quantum__rt__heap_alloc(i32 %size) { - %mem = call i8* @quantum__rt__heap_alloc(i32 %size) +define dllexport i8* @__quantum__rt__heap_alloc(i64 %size) { + %mem = call i8* @quantum__rt__heap_alloc(i64 %size) ret i8* %mem } @@ -121,6 +126,12 @@ define dllexport void @__quantum__rt__heap_free(i8* %mem) { ret void } +; Returns a pointer to the malloc-allocated block. +define dllexport i8* @__quantum__rt__memory_allocate(i64 %size) { + %result = call i8* @quantum__rt__memory_allocate(i64 %size) + ret i8* %result +} + define dllexport void @__quantum__rt__fail(%String* %.str) { %str = bitcast %String* %.str to %"struct.QirString"* call void @quantum__rt__fail(%"struct.QirString"* %str) @@ -172,13 +183,24 @@ define dllexport i1 @__quantum__rt__result_equal(%Result* %.r1, %Result* %.r2) { ret i1 %c } -define dllexport void @__quantum__rt__result_update_reference_count(%Result* %.r, i64 %.c) { +define dllexport void @__quantum__rt__result_update_reference_count(%Result* %.r, i32 %c) { %r = bitcast %Result* %.r to %class.RESULT* - %c = trunc i64 %.c to i32 call void @quantum__rt__result_update_reference_count(%class.RESULT* %r, i32 %c) ret void } +define dllexport %Result* @__quantum__rt__result_get_zero() { + %result = call %class.RESULT* @quantum__rt__result_get_zero() + %.result = bitcast %class.RESULT* %result to %Result* + ret %Result* %.result +} + +define dllexport %Result* @__quantum__rt__result_get_one() { + %result = call %class.RESULT* @quantum__rt__result_get_one() + %.result = bitcast %class.RESULT* %result to %Result* + ret %Result* %.result +} + ; ----------------------------------------------------------------------------- ; arrays bridge @@ -276,16 +298,14 @@ define dllexport %Array* @__quantum__rt__array_slice_1d(%Array* %.ar, %Range %.r ret %Array* %.slice } -define dllexport void @__quantum__rt__array_update_reference_count(%Array* %.ar, i64 %.c) { +define dllexport void @__quantum__rt__array_update_reference_count(%Array* %.ar, i32 %c) { %ar = bitcast %Array* %.ar to %"struct.QirArray"* - %c = trunc i64 %.c to i32 call void @quantum__rt__array_update_reference_count(%"struct.QirArray"* %ar, i32 %c) ret void } -define dllexport void @__quantum__rt__array_update_alias_count(%Array* %.ar, i64 %.c) { +define dllexport void @__quantum__rt__array_update_alias_count(%Array* %.ar, i32 %c) { %ar = bitcast %Array* %.ar to %"struct.QirArray"* - %c = trunc i64 %.c to i32 call void @quantum__rt__array_update_alias_count(%"struct.QirArray"* %ar, i32 %c) ret void } @@ -299,16 +319,14 @@ define dllexport %Tuple* @__quantum__rt__tuple_create(i64 %size) { ret %Tuple* %.th } -define dllexport void @__quantum__rt__tuple_update_reference_count(%Tuple* %.th, i64 %.c) { +define dllexport void @__quantum__rt__tuple_update_reference_count(%Tuple* %.th, i32 %c) { %th = bitcast %Tuple* %.th to i8* - %c = trunc i64 %.c to i32 call void @quantum__rt__tuple_update_reference_count(i8* %th, i32 %c) ret void } -define dllexport void @__quantum__rt__tuple_update_alias_count(%Tuple* %.th, i64 %.c) { +define dllexport void @__quantum__rt__tuple_update_alias_count(%Tuple* %.th, i32 %c) { %th = bitcast %Tuple* %.th to i8* - %c = trunc i64 %.c to i32 call void @quantum__rt__tuple_update_alias_count(i8* %th, i32 %c) ret void } @@ -316,16 +334,14 @@ define dllexport void @__quantum__rt__tuple_update_alias_count(%Tuple* %.th, i64 ;------------------------------------------------------------------------------ ; callables bridge ; -define dllexport void @__quantum__rt__callable_update_reference_count(%Callable* %.clb, i64 %.c) { +define dllexport void @__quantum__rt__callable_update_reference_count(%Callable* %.clb, i32 %c) { %clb = bitcast %Callable* %.clb to %"struct.QirCallable"* - %c = trunc i64 %.c to i32 call void @quantum__rt__callable_update_reference_count(%"struct.QirCallable"* %clb, i32 %c) ret void } -define dllexport void @__quantum__rt__callable_update_alias_count(%Callable* %.clb, i64 %.c) { +define dllexport void @__quantum__rt__callable_update_alias_count(%Callable* %.clb, i32 %c) { %clb = bitcast %Callable* %.clb to %"struct.QirCallable"* - %c = trunc i64 %.c to i32 call void @quantum__rt__callable_update_alias_count(%"struct.QirCallable"* %clb, i32 %c) ret void } @@ -370,26 +386,46 @@ define dllexport %Callable* @__quantum__rt__callable_make_controlled(%Callable* ret %Callable* %.clb_cnt } -define dllexport void @__quantum__rt__callable_memory_management(i32 %index, %Callable* %.clb, i64 %parameter) { +; After both the compiler and runtime are in sync with https://github.com/microsoft/qsharp-language/pull/83: +; Regenerate the following .ll files with the updated compiler such that they don't call this function any more: +; test\FullstateSimulator\qir-test-simulator.ll +; test\QIR-tracer\tracer-qir-lnx.ll +; test\QIR-tracer\tracer-qir-win.ll +; Remove this function. +; Resolve https://github.com/microsoft/qsharp-runtime/issues/568 (Remove `__quantum__rt__callable_memory_management()`) +define dllexport void @__quantum__rt__callable_memory_management(i32 %index, %Callable* %.clb, i64 %.parameter) { + %clb = bitcast %Callable* %.clb to %"struct.QirCallable"* + %parameter = trunc i64 %.parameter to i32 + call void @quantum__rt__callable_memory_management(i32 %index, %"struct.QirCallable"* %clb, i32 %parameter) + ret void +} + +define dllexport void @__quantum__rt__capture_update_reference_count(%Callable* %.clb, i32 %count) { + %clb = bitcast %Callable* %.clb to %"struct.QirCallable"* + call void @quantum__rt__callable_memory_management(i32 0, %"struct.QirCallable"* %clb, i32 %count) + ret void +} + +define dllexport void @__quantum__rt__capture_update_alias_count(%Callable* %.clb, i32 %count) { %clb = bitcast %Callable* %.clb to %"struct.QirCallable"* - call void @quantum__rt__callable_memory_management(i32 %index, %"struct.QirCallable"* %clb, i64 %parameter) + call void @quantum__rt__callable_memory_management(i32 1, %"struct.QirCallable"* %clb, i32 %count) ret void } + ;------------------------------------------------------------------------------ ; strings bridge ; ; NYI: ;define dllexport %String* @__quantum__rt__bigint_to_string(%BigInt*) -define dllexport %String* @__quantum__rt__string_create(i32 %length_ignored, i8* %null_terminated_buffer) { +define dllexport %String* @__quantum__rt__string_create(i8* %null_terminated_buffer) { %str = call %"struct.QirString"* @quantum__rt__string_create(i8* %null_terminated_buffer) %.str = bitcast %"struct.QirString"* %str to %String* ret %String* %.str } -define dllexport void @__quantum__rt__string_update_reference_count(%String* %.str, i64 %.c) { +define dllexport void @__quantum__rt__string_update_reference_count(%String* %.str, i32 %c) { %str = bitcast %String* %.str to %"struct.QirString"* - %c = trunc i64 %.c to i32 call void @quantum__rt__string_update_reference_count(%"struct.QirString"* %str, i32 %c) ret void } @@ -458,13 +494,26 @@ define dllexport %String* @__quantum__rt__range_to_string(%Range %.range) { ret %String* %.str } +define i8* @__quantum__rt_string_get_data(%String* %.str) { + %str = bitcast %String* %.str to %"struct.QirString"* + %result = call i8* @quantum__rt_string_get_data(%"struct.QirString"* %str) + ret i8* %result +} + +define i32 @__quantum__rt_string_get_length(%String* %.str) { + %str = bitcast %String* %.str to %"struct.QirString"* + %result = call i32 @quantum__rt_string_get_length(%"struct.QirString"* %str) + ret i32 %result +} + + ;------------------------------------------------------------------------------ ; bigints bridge ; ; NYI: ;define dllexport %BigInt* @__quantum__rt__bigint_create_i64(i64) ;define dllexport %BigInt* @__quantum__rt__bigint_create_array(i32, [0 x i8]) -;define dllexport void @__quantum__rt__bigint_update_reference_count(%BigInt*, i64) +;define dllexport void @__quantum__rt__bigint_update_reference_count(%BigInt*, i32) ;define dllexport %BigInt* @__quantum__rt__bigint_negate(%BigInt*) ;define dllexport %BigInt* @__quantum__rt__bigint_add(%BigInt*, %BigInt*) ;define dllexport %BigInt* @__quantum__rt__bigint_subtract(%BigInt*, %BigInt*) diff --git a/src/QirRuntime/lib/QIR/callables.cpp b/src/QirRuntime/lib/QIR/callables.cpp index 454eb4f3dbf..503ae8c1bf6 100644 --- a/src/QirRuntime/lib/QIR/callables.cpp +++ b/src/QirRuntime/lib/QIR/callables.cpp @@ -153,7 +153,7 @@ extern "C" callable->ApplyFunctor(QirCallable::Controlled); } - void quantum__rt__callable_memory_management(int32_t index, QirCallable* callable, int64_t parameter) + void quantum__rt__callable_memory_management(int32_t index, QirCallable* callable, int32_t parameter) { callable->InvokeCaptureCallback(index, parameter); } @@ -443,7 +443,7 @@ void QirCallable::ApplyFunctor(int functor) } } -void QirCallable::InvokeCaptureCallback(int index, int64_t parameter) +void QirCallable::InvokeCaptureCallback(int32_t index, int32_t parameter) { assert(index >= 0 && index < QirCallable::CaptureCallbacksTableSize && "Capture callback index out of range"); diff --git a/src/QirRuntime/lib/QIR/delegated.cpp b/src/QirRuntime/lib/QIR/delegated.cpp index 7100fcef9aa..8d466b086f4 100644 --- a/src/QirRuntime/lib/QIR/delegated.cpp +++ b/src/QirRuntime/lib/QIR/delegated.cpp @@ -27,12 +27,12 @@ std::unordered_map& AllocatedResults() extern "C" { - Result quantum__rt__result_zero() + Result quantum__rt__result_get_zero() { return Microsoft::Quantum::g_context->driver->UseZero(); } - Result quantum__rt__result_one() + Result quantum__rt__result_get_one() { return Microsoft::Quantum::g_context->driver->UseOne(); } diff --git a/src/QirRuntime/lib/QIR/strings.cpp b/src/QirRuntime/lib/QIR/strings.cpp index 21f3b571d14..49a2c40dffb 100644 --- a/src/QirRuntime/lib/QIR/strings.cpp +++ b/src/QirRuntime/lib/QIR/strings.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "QirTypes.hpp" #include "QirRuntime.hpp" @@ -155,6 +156,16 @@ extern "C" return quantum__rt__string_create(oss.str().c_str()); } + const char* quantum__rt_string_get_data(QirString* str) // NOLINT + { + return str->str.c_str(); + } + + uint32_t quantum__rt_string_get_length(QirString* str) // NOLINT + { + return str->str.size(); + } + // Implemented in delegated.cpp: // QirString* quantum__rt__qubit_to_string(QUBIT* qubit); // NOLINT diff --git a/src/QirRuntime/lib/QIR/utils.cpp b/src/QirRuntime/lib/QIR/utils.cpp index 6f024cdfafe..00bd1959ed5 100644 --- a/src/QirRuntime/lib/QIR/utils.cpp +++ b/src/QirRuntime/lib/QIR/utils.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include "QirRuntime.hpp" @@ -20,9 +22,13 @@ std::unordered_set& UseMemoryTracker() extern "C" { // Allocate a block of memory on the heap. - char* quantum__rt__heap_alloc(int size) // NOLINT + char* quantum__rt__heap_alloc(uint64_t size) // NOLINT { - char* buffer = new char[size]; + char* buffer = new (std::nothrow) char[size]; + if(buffer == nullptr) + { + quantum__rt__fail(quantum__rt__string_create("Allocation Failed")); + } #ifndef NDEBUG UseMemoryTracker().insert(buffer); #endif @@ -40,6 +46,11 @@ extern "C" delete[] buffer; } + char* quantum__rt__memory_allocate(uint64_t size) + { + return (char *)malloc((size_t)size); + } + // Fail the computation with the given error message. void quantum__rt__fail(QirString* msg) // NOLINT { diff --git a/src/QirRuntime/lib/QSharpFoundation/conditionals.cpp b/src/QirRuntime/lib/QSharpFoundation/conditionals.cpp index 048ce01eadb..64e46c846f2 100644 --- a/src/QirRuntime/lib/QSharpFoundation/conditionals.cpp +++ b/src/QirRuntime/lib/QSharpFoundation/conditionals.cpp @@ -31,7 +31,7 @@ extern "C" { void quantum__qis__applyifelseintrinsic__body(RESULT* r, QirCallable* clbOnZero, QirCallable* clbOnOne) { - QirCallable* clb = quantum__rt__result_equal(r, quantum__rt__result_zero()) ? clbOnZero : clbOnOne; + QirCallable* clb = quantum__rt__result_equal(r, quantum__rt__result_get_zero()) ? clbOnZero : clbOnOne; clb->Invoke(); } diff --git a/src/QirRuntime/public/QirRuntime.hpp b/src/QirRuntime/public/QirRuntime.hpp index eedcdf659b4..563af6a2d50 100644 --- a/src/QirRuntime/public/QirRuntime.hpp +++ b/src/QirRuntime/public/QirRuntime.hpp @@ -56,11 +56,14 @@ extern "C" // ------------------------------------------------------------------------ // Allocate a block of memory on the heap. - QIR_SHARED_API char* quantum__rt__heap_alloc(int size); // NOLINT + QIR_SHARED_API char* quantum__rt__heap_alloc(uint64_t size); // NOLINT // Release a block of allocated heap memory. QIR_SHARED_API void quantum__rt__heap_free(char* buffer); // NOLINT + // Returns a pointer to the malloc-allocated block. + QIR_SHARED_API char* quantum__rt__memory_allocate(uint64_t size); // NOLINT + // Fail the computation with the given error message. QIR_SHARED_API void quantum__rt__fail(QirString* msg); // NOLINT @@ -78,9 +81,8 @@ extern "C" // becomes 0. The behavior is undefined if the reference count becomes negative. QIR_SHARED_API void quantum__rt__result_update_reference_count(RESULT*, int32_t); // NOLINT - // Not in the QIR spec right now - QIR_SHARED_API RESULT* quantum__rt__result_one(); // NOLINT - QIR_SHARED_API RESULT* quantum__rt__result_zero(); // NOLINT + QIR_SHARED_API RESULT* quantum__rt__result_get_one(); // NOLINT + QIR_SHARED_API RESULT* quantum__rt__result_get_zero(); // NOLINT // ------------------------------------------------------------------------ // Tuples @@ -160,7 +162,6 @@ extern "C" // Initializes the callable with the provided function table and capture tuple. The capture tuple pointer // should be null if there is no capture. typedef void (*t_CallableEntry)(PTuple, PTuple, PTuple); // NOLINT - typedef void (*t_CaptureCallback)(PTuple, int64_t); // NOLINT QIR_SHARED_API QirCallable* quantum__rt__callable_create(t_CallableEntry*, t_CaptureCallback*, PTuple); // NOLINT // Adds the given integer value to the reference count for the callable. Deallocates the callable if the reference @@ -184,9 +185,9 @@ extern "C" QIR_SHARED_API void quantum__rt__callable_make_controlled(QirCallable*); // NOLINT // Invokes the function at the given index in the memory management table of the callable with the capture tuple and - // the given 64-bit integer. Does nothing if if the memory management table pointer or the function pointer at that + // the given 32-bit integer. Does nothing if the memory management table pointer or the function pointer at that // index is null. - QIR_SHARED_API void quantum__rt__callable_memory_management(int32_t, QirCallable*, int64_t); // NOLINT + QIR_SHARED_API void quantum__rt__callable_memory_management(int32_t, QirCallable*, int32_t); // NOLINT // ------------------------------------------------------------------------ // Strings @@ -228,6 +229,14 @@ extern "C" // Returns a string representation of the range. QIR_SHARED_API QirString* quantum__rt__range_to_string(const QirRange&); // NOLINT + // Returns a pointer to an array that contains a null-terminated sequence of characters + // (i.e., a C-string) representing the current value of the string object. + QIR_SHARED_API const char* quantum__rt_string_get_data(QirString* str); // NOLINT + + // Returns the length of the string, in terms of bytes. + // http://www.cplusplus.com/reference/string/string/size/ + QIR_SHARED_API uint32_t quantum__rt_string_get_length(QirString* str); // NOLINT + // Returns a string representation of the big integer. // TODO QIR_SHARED_API QirString* quantum__rt__bigint_to_string(QirBigInt*); // NOLINT diff --git a/src/QirRuntime/public/QirTypes.hpp b/src/QirRuntime/public/QirTypes.hpp index 6b144975346..02b1d686f68 100644 --- a/src/QirRuntime/public/QirTypes.hpp +++ b/src/QirRuntime/public/QirTypes.hpp @@ -63,7 +63,7 @@ struct QIR_SHARED_API QirTupleHeader { int32_t refCount = 0; int32_t aliasCount = 0; // used to enable copy elision, see the QIR specifications for details - int32_t tupleSize = 0; // when creating the tuple, must be set to the size of the tuple's data buffer + int32_t tupleSize = 0; // when creating the tuple, must be set to the size of the tuple's data buffer (in bytes) // flexible array member, must be last in the struct char data[]; @@ -121,7 +121,7 @@ static_assert( QirCallable ======================================================================================================================*/ typedef void (*t_CallableEntry)(PTuple, PTuple, PTuple); -typedef void (*t_CaptureCallback)(PTuple, int64_t); +typedef void (*t_CaptureCallback)(PTuple, int32_t); struct QIR_SHARED_API QirCallable { static int constexpr Adjoint = 1; @@ -171,5 +171,5 @@ struct QIR_SHARED_API QirCallable void Invoke(); // a shortcut to invoke a callable with no arguments and Unit result void ApplyFunctor(int functor); - void InvokeCaptureCallback(int index, int64_t parameter); + void InvokeCaptureCallback(int32_t index, int32_t parameter); }; \ No newline at end of file diff --git a/src/QirRuntime/samples/StandaloneInputReference/qir-standalone-input-reference.ll b/src/QirRuntime/samples/StandaloneInputReference/qir-standalone-input-reference.ll deleted file mode 100644 index d990f34df62..00000000000 --- a/src/QirRuntime/samples/StandaloneInputReference/qir-standalone-input-reference.ll +++ /dev/null @@ -1,77 +0,0 @@ - -%Result = type opaque -%Range = type { i64, i64, i64 } -%String = type opaque - -@ResultZero = external global %Result* -@ResultOne = external global %Result* -@PauliI = constant i2 0 -@PauliX = constant i2 1 -@PauliY = constant i2 -1 -@PauliZ = constant i2 -2 -@EmptyRange = internal constant %Range { i64 0, i64 1, i64 -1 } -@0 = internal constant [26 x i8] c"Exercise Supported Inputs\00" -@1 = internal constant [11 x i8] c"intValue: \00" -@2 = internal constant [14 x i8] c"doubleValue: \00" -@3 = internal constant [14 x i8] c"resultValue: \00" -@4 = internal constant [14 x i8] c"stringValue: \00" - -@Quantum__StandaloneSupportedInputs__ExerciseInputs = alias i64 (i64, double, %Result*, %String*), i64 (i64, double, %Result*, %String*)* @Quantum__StandaloneSupportedInputs__ExerciseInputs__body - -define i64 @Quantum__StandaloneSupportedInputs__ExerciseInputs__body(i64 %intValue, double %doubleValue, %Result* %resultValue, %String* %stringValue) #0 { -entry: - %msg = call %String* @__quantum__rt__string_create(i32 25, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @0, i32 0, i32 0)) - call void @__quantum__qis__message__body(%String* %msg) - call void @__quantum__rt__string_update_reference_count(%String* %msg, i64 -1) - %0 = call %String* @__quantum__rt__string_create(i32 10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @1, i32 0, i32 0)) - %1 = call %String* @__quantum__rt__int_to_string(i64 %intValue) - %msg__1 = call %String* @__quantum__rt__string_concatenate(%String* %0, %String* %1) - call void @__quantum__rt__string_update_reference_count(%String* %0, i64 -1) - call void @__quantum__rt__string_update_reference_count(%String* %1, i64 -1) - call void @__quantum__qis__message__body(%String* %msg__1) - call void @__quantum__rt__string_update_reference_count(%String* %msg__1, i64 -1) - %2 = call %String* @__quantum__rt__string_create(i32 13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @2, i32 0, i32 0)) - %3 = call %String* @__quantum__rt__double_to_string(double %doubleValue) - %msg__2 = call %String* @__quantum__rt__string_concatenate(%String* %2, %String* %3) - call void @__quantum__rt__string_update_reference_count(%String* %2, i64 -1) - call void @__quantum__rt__string_update_reference_count(%String* %3, i64 -1) - call void @__quantum__qis__message__body(%String* %msg__2) - call void @__quantum__rt__string_update_reference_count(%String* %msg__2, i64 -1) - %4 = call %String* @__quantum__rt__string_create(i32 13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @3, i32 0, i32 0)) - %5 = call %String* @__quantum__rt__result_to_string(%Result* %resultValue) - %msg__3 = call %String* @__quantum__rt__string_concatenate(%String* %4, %String* %5) - call void @__quantum__rt__string_update_reference_count(%String* %4, i64 -1) - call void @__quantum__rt__string_update_reference_count(%String* %5, i64 -1) - call void @__quantum__qis__message__body(%String* %msg__3) - call void @__quantum__rt__string_update_reference_count(%String* %msg__3, i64 -1) - %6 = call %String* @__quantum__rt__string_create(i32 13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @4, i32 0, i32 0)) - call void @__quantum__rt__string_update_reference_count(%String* %stringValue, i64 1) - %msg__4 = call %String* @__quantum__rt__string_concatenate(%String* %6, %String* %stringValue) - call void @__quantum__rt__string_update_reference_count(%String* %6, i64 -1) - call void @__quantum__rt__string_update_reference_count(%String* %stringValue, i64 -1) - call void @__quantum__qis__message__body(%String* %msg__4) - call void @__quantum__rt__string_update_reference_count(%String* %msg__4, i64 -1) - ret i64 0 -} - -declare %String* @__quantum__rt__string_create(i32, i8*) - -declare void @__quantum__qis__message__body(%String*) - -declare void @__quantum__rt__string_update_reference_count(%String*, i64) - -declare %String* @__quantum__rt__int_to_string(i64) - -declare %String* @__quantum__rt__string_concatenate(%String*, %String*) - -declare %String* @__quantum__rt__double_to_string(double) - -declare %String* @__quantum__rt__result_to_string(%Result*) - -define void @Microsoft__Quantum__Intrinsic__Message__body(%String* %msg) { -entry: - call void @__quantum__qis__message__body(%String* %msg) - ret void -} - -attributes #0 = { "EntryPoint" } diff --git a/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj b/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj index 5878e9774c3..74ef21518f7 100644 --- a/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj +++ b/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj @@ -1,4 +1,4 @@ - + Exe @@ -6,4 +6,8 @@ True + + + + diff --git a/src/QirRuntime/test-qir-runtime.ps1 b/src/QirRuntime/test-qir-runtime.ps1 index ecf02e60823..5a96cbb7843 100644 --- a/src/QirRuntime/test-qir-runtime.ps1 +++ b/src/QirRuntime/test-qir-runtime.ps1 @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +& (Join-Path $PSScriptRoot .. .. build set-env.ps1) $all_ok = $true Write-Host "##[info]Test QIR Runtime" diff --git a/src/QirRuntime/test/FullstateSimulator/qir-test-simulator.ll b/src/QirRuntime/test/FullstateSimulator/qir-test-simulator.ll deleted file mode 100644 index dd0bebfe9a1..00000000000 --- a/src/QirRuntime/test/FullstateSimulator/qir-test-simulator.ll +++ /dev/null @@ -1,1398 +0,0 @@ - -%Result = type opaque -%Range = type { i64, i64, i64 } -%Tuple = type opaque -%Qubit = type opaque -%Array = type opaque -%Callable = type opaque - -@ResultZero = external global %Result* -@ResultOne = external global %Result* -@PauliI = constant i2 0 -@PauliX = constant i2 1 -@PauliY = constant i2 -1 -@PauliZ = constant i2 -2 -@EmptyRange = internal constant %Range { i64 0, i64 1, i64 -1 } -@Microsoft__Quantum__Intrinsic__X = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__X__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__X__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__X__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__X__ctladj__wrapper] -@Microsoft__Quantum__Intrinsic__Y = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Y__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Y__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Y__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Y__ctladj__wrapper] -@Microsoft__Quantum__Intrinsic__Z = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Z__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Z__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Z__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Z__ctladj__wrapper] -@Microsoft__Quantum__Intrinsic__H = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__H__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__H__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__H__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__H__ctladj__wrapper] -@Microsoft__Quantum__Intrinsic__S = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__S__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__S__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__S__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__S__ctladj__wrapper] -@Microsoft__Quantum__Intrinsic__T = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__T__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__T__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__T__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__T__ctladj__wrapper] -@Microsoft__Quantum__Intrinsic__R = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__R__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__R__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__R__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__R__ctladj__wrapper] -@PartialApplication__1 = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Lifted__PartialApplication__1__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Lifted__PartialApplication__1__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Lifted__PartialApplication__1__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Lifted__PartialApplication__1__ctladj__wrapper] -@MemoryManagement__1 = constant [2 x void (%Tuple*, i64)*] [void (%Tuple*, i64)* @MemoryManagement__1__RefCount, void (%Tuple*, i64)* @MemoryManagement__1__AliasCount] - -@Microsoft__Quantum__Testing__QIR__Test_Simulator_QIS = alias i64 (), i64 ()* @Microsoft__Quantum__Testing__QIR__Test_Simulator_QIS__body - -define void @Microsoft__Quantum__Intrinsic__X__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__x__body(%Qubit* %qb) - ret void -} - -declare void @__quantum__qis__x__body(%Qubit*) - -define void @Microsoft__Quantum__Intrinsic__X__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__x__body(%Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__ctl(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__x__ctl(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -declare void @__quantum__rt__array_update_alias_count(%Array*, i64) - -declare void @__quantum__qis__x__ctl(%Array*, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__X__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__x__ctl(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -define %Result* @Microsoft__Quantum__Intrinsic__M__body(%Qubit* %qb) { -entry: - %bases__inline__1 = call %Array* @__quantum__rt__array_create_1d(i32 1, i64 1) - %0 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %bases__inline__1, i64 0) - %1 = bitcast i8* %0 to i2* - %2 = load i2, i2* @PauliZ - store i2 %2, i2* %1 - call void @__quantum__rt__array_update_alias_count(%Array* %bases__inline__1, i64 1) - %qubits__inline__1 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %3 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qubits__inline__1, i64 0) - %4 = bitcast i8* %3 to %Qubit** - store %Qubit* %qb, %Qubit** %4 - call void @__quantum__rt__array_update_alias_count(%Array* %qubits__inline__1, i64 1) - %5 = call %Result* @__quantum__qis__measure__body(%Array* %bases__inline__1, %Array* %qubits__inline__1) - call void @__quantum__rt__array_update_alias_count(%Array* %bases__inline__1, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits__inline__1, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %bases__inline__1, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %qubits__inline__1, i64 -1) - ret %Result* %5 -} - -declare %Array* @__quantum__rt__array_create_1d(i32, i64) - -declare i8* @__quantum__rt__array_get_element_ptr_1d(%Array*, i64) - -declare %Result* @__quantum__qis__measure__body(%Array*, %Array*) - -declare void @__quantum__rt__array_update_reference_count(%Array*, i64) - -define void @Microsoft__Quantum__Intrinsic__S__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__s__body(%Qubit* %qb) - ret void -} - -declare void @__quantum__qis__s__body(%Qubit*) - -define void @Microsoft__Quantum__Intrinsic__S__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__s__adj(%Qubit* %qb) - ret void -} - -declare void @__quantum__qis__s__adj(%Qubit*) - -define void @Microsoft__Quantum__Intrinsic__S__ctl(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__s__ctl(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -declare void @__quantum__qis__s__ctl(%Array*, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__S__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__s__ctladj(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -declare void @__quantum__qis__s__ctladj(%Array*, %Qubit*) - -define %Result* @Microsoft__Quantum__Intrinsic__Measure__body(%Array* %bases, %Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %bases, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %0 = call %Result* @__quantum__qis__measure__body(%Array* %bases, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %bases, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret %Result* %0 -} - -define void @Microsoft__Quantum__Intrinsic__T__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__t__body(%Qubit* %qb) - ret void -} - -declare void @__quantum__qis__t__body(%Qubit*) - -define void @Microsoft__Quantum__Intrinsic__T__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__t__adj(%Qubit* %qb) - ret void -} - -declare void @__quantum__qis__t__adj(%Qubit*) - -define void @Microsoft__Quantum__Intrinsic__T__ctl(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__t__ctl(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -declare void @__quantum__qis__t__ctl(%Array*, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__T__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__t__ctladj(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -declare void @__quantum__qis__t__ctladj(%Array*, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__H__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__h__body(%Qubit* %qb) - ret void -} - -declare void @__quantum__qis__h__body(%Qubit*) - -define void @Microsoft__Quantum__Intrinsic__H__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__h__body(%Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__H__ctl(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__h__ctl(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -declare void @__quantum__qis__h__ctl(%Array*, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__H__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__h__ctl(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__y__body(%Qubit* %qb) - ret void -} - -declare void @__quantum__qis__y__body(%Qubit*) - -define void @Microsoft__Quantum__Intrinsic__Y__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__y__body(%Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__ctl(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__y__ctl(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -declare void @__quantum__qis__y__ctl(%Array*, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__Y__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__y__ctl(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__R__body(i2 %pauli, double %theta, %Qubit* %qubit) { -entry: - call void @__quantum__qis__r__body(i2 %pauli, double %theta, %Qubit* %qubit) - ret void -} - -declare void @__quantum__qis__r__body(i2, double, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__R__adj(i2 %pauli, double %theta, %Qubit* %qubit) { -entry: - call void @__quantum__qis__r__adj(i2 %pauli, double %theta, %Qubit* %qubit) - ret void -} - -declare void @__quantum__qis__r__adj(i2, double, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__R__ctl(%Array* %__controlQubits__, { i2, double, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - %1 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %0, i64 0, i32 0 - %pauli = load i2, i2* %1 - %2 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %0, i64 0, i32 1 - %theta = load double, double* %2 - %3 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %0, i64 0, i32 2 - %qubit = load %Qubit*, %Qubit** %3 - %4 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint ({ i2, double, %Qubit* }* getelementptr ({ i2, double, %Qubit* }, { i2, double, %Qubit* }* null, i32 1) to i64)) - %5 = bitcast %Tuple* %4 to { i2, double, %Qubit* }* - %6 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %5, i64 0, i32 0 - %7 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %5, i64 0, i32 1 - %8 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %5, i64 0, i32 2 - store i2 %pauli, i2* %6 - store double %theta, double* %7 - store %Qubit* %qubit, %Qubit** %8 - call void @__quantum__qis__r__ctl(%Array* %__controlQubits__, { i2, double, %Qubit* }* %5) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %4, i64 -1) - ret void -} - -declare void @__quantum__qis__r__ctl(%Array*, { i2, double, %Qubit* }*) - -declare %Tuple* @__quantum__rt__tuple_create(i64) - -declare void @__quantum__rt__tuple_update_reference_count(%Tuple*, i64) - -define void @Microsoft__Quantum__Intrinsic__R__ctladj(%Array* %__controlQubits__, { i2, double, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - %1 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %0, i64 0, i32 0 - %pauli = load i2, i2* %1 - %2 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %0, i64 0, i32 1 - %theta = load double, double* %2 - %3 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %0, i64 0, i32 2 - %qubit = load %Qubit*, %Qubit** %3 - %4 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint ({ i2, double, %Qubit* }* getelementptr ({ i2, double, %Qubit* }, { i2, double, %Qubit* }* null, i32 1) to i64)) - %5 = bitcast %Tuple* %4 to { i2, double, %Qubit* }* - %6 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %5, i64 0, i32 0 - %7 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %5, i64 0, i32 1 - %8 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %5, i64 0, i32 2 - store i2 %pauli, i2* %6 - store double %theta, double* %7 - store %Qubit* %qubit, %Qubit** %8 - call void @__quantum__qis__r__ctladj(%Array* %__controlQubits__, { i2, double, %Qubit* }* %5) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %4, i64 -1) - ret void -} - -declare void @__quantum__qis__r__ctladj(%Array*, { i2, double, %Qubit* }*) - -define void @Microsoft__Quantum__Intrinsic__Exp__body(%Array* %paulis, double %theta, %Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - call void @__quantum__qis__exp__body(%Array* %paulis, double %theta, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret void -} - -declare void @__quantum__qis__exp__body(%Array*, double, %Array*) - -define void @Microsoft__Quantum__Intrinsic__Exp__adj(%Array* %paulis, double %theta, %Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - call void @__quantum__qis__exp__adj(%Array* %paulis, double %theta, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret void -} - -declare void @__quantum__qis__exp__adj(%Array*, double, %Array*) - -define void @Microsoft__Quantum__Intrinsic__Exp__ctl(%Array* %__controlQubits__, { %Array*, double, %Array* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - %1 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %0, i64 0, i32 0 - %paulis = load %Array*, %Array** %1 - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 1) - %2 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %0, i64 0, i32 1 - %theta = load double, double* %2 - %3 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %0, i64 0, i32 2 - %qubits = load %Array*, %Array** %3 - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %4 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint ({ %Array*, double, %Array* }* getelementptr ({ %Array*, double, %Array* }, { %Array*, double, %Array* }* null, i32 1) to i64)) - %5 = bitcast %Tuple* %4 to { %Array*, double, %Array* }* - %6 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %5, i64 0, i32 0 - %7 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %5, i64 0, i32 1 - %8 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %5, i64 0, i32 2 - store %Array* %paulis, %Array** %6 - store double %theta, double* %7 - store %Array* %qubits, %Array** %8 - call void @__quantum__qis__exp__ctl(%Array* %__controlQubits__, { %Array*, double, %Array* }* %5) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %4, i64 -1) - ret void -} - -declare void @__quantum__qis__exp__ctl(%Array*, { %Array*, double, %Array* }*) - -define void @Microsoft__Quantum__Intrinsic__Exp__ctladj(%Array* %__controlQubits__, { %Array*, double, %Array* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - %1 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %0, i64 0, i32 0 - %paulis = load %Array*, %Array** %1 - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 1) - %2 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %0, i64 0, i32 1 - %theta = load double, double* %2 - %3 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %0, i64 0, i32 2 - %qubits = load %Array*, %Array** %3 - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %4 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint ({ %Array*, double, %Array* }* getelementptr ({ %Array*, double, %Array* }, { %Array*, double, %Array* }* null, i32 1) to i64)) - %5 = bitcast %Tuple* %4 to { %Array*, double, %Array* }* - %6 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %5, i64 0, i32 0 - %7 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %5, i64 0, i32 1 - %8 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %5, i64 0, i32 2 - store %Array* %paulis, %Array** %6 - store double %theta, double* %7 - store %Array* %qubits, %Array** %8 - call void @__quantum__qis__exp__ctladj(%Array* %__controlQubits__, { %Array*, double, %Array* }* %5) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %4, i64 -1) - ret void -} - -declare void @__quantum__qis__exp__ctladj(%Array*, { %Array*, double, %Array* }*) - -define void @Microsoft__Quantum__Intrinsic__Z__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__z__body(%Qubit* %qb) - ret void -} - -declare void @__quantum__qis__z__body(%Qubit*) - -define void @Microsoft__Quantum__Intrinsic__Z__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__z__body(%Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__ctl(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__z__ctl(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -declare void @__quantum__qis__z__ctl(%Array*, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__Z__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__z__ctl(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -define i64 @Microsoft__Quantum__Testing__QIR__InvokeAllVariants__body(%Callable* %op) { -entry: - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %op, i64 1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %op, i64 1) - %res = alloca i64 - store i64 0, i64* %res - %target = call %Qubit* @__quantum__rt__qubit_allocate() - %ctls = call %Array* @__quantum__rt__qubit_allocate_array(i64 2) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %0 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64)) - %1 = bitcast %Tuple* %0 to { %Qubit* }* - %2 = getelementptr { %Qubit* }, { %Qubit* }* %1, i64 0, i32 0 - store %Qubit* %target, %Qubit** %2 - call void @__quantum__rt__callable_invoke(%Callable* %op, %Tuple* %0, %Tuple* null) - %3 = call %Callable* @__quantum__rt__callable_copy(%Callable* %op, i1 false) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %3, i64 1) - call void @__quantum__rt__callable_make_adjoint(%Callable* %3) - %4 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64)) - %5 = bitcast %Tuple* %4 to { %Qubit* }* - %6 = getelementptr { %Qubit* }, { %Qubit* }* %5, i64 0, i32 0 - store %Qubit* %target, %Qubit** %6 - call void @__quantum__rt__callable_invoke(%Callable* %3, %Tuple* %4, %Tuple* null) - %7 = call %Result* @Microsoft__Quantum__Intrinsic__M__body(%Qubit* %target) - %8 = load %Result*, %Result** @ResultZero - %9 = call i1 @__quantum__rt__result_equal(%Result* %7, %Result* %8) - %10 = xor i1 %9, true - br i1 %10, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - store i64 1, i64* %res - br label %continue__1 - -else__1: ; preds = %entry - %11 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls, i64 0) - %12 = bitcast i8* %11 to %Qubit** - %qb__inline__1 = load %Qubit*, %Qubit** %12 - call void @__quantum__qis__h__body(%Qubit* %qb__inline__1) - %13 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls, i64 1) - %14 = bitcast i8* %13 to %Qubit** - %qb__inline__2 = load %Qubit*, %Qubit** %14 - call void @__quantum__qis__h__body(%Qubit* %qb__inline__2) - %15 = call %Callable* @__quantum__rt__callable_copy(%Callable* %op, i1 false) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %15, i64 1) - call void @__quantum__rt__callable_make_controlled(%Callable* %15) - %16 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 2)) - %17 = bitcast %Tuple* %16 to { %Array*, %Qubit* }* - %18 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %17, i64 0, i32 0 - %19 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %17, i64 0, i32 1 - store %Array* %ctls, %Array** %18 - store %Qubit* %target, %Qubit** %19 - call void @__quantum__rt__callable_invoke(%Callable* %15, %Tuple* %16, %Tuple* null) - %20 = call %Callable* @__quantum__rt__callable_copy(%Callable* %op, i1 false) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %20, i64 1) - call void @__quantum__rt__callable_make_controlled(%Callable* %20) - call void @__quantum__rt__callable_make_adjoint(%Callable* %20) - %21 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 2)) - %22 = bitcast %Tuple* %21 to { %Array*, %Qubit* }* - %23 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %22, i64 0, i32 0 - %24 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %22, i64 0, i32 1 - store %Array* %ctls, %Array** %23 - store %Qubit* %target, %Qubit** %24 - call void @__quantum__rt__callable_invoke(%Callable* %20, %Tuple* %21, %Tuple* null) - %25 = call %Result* @Microsoft__Quantum__Intrinsic__M__body(%Qubit* %target) - %26 = load %Result*, %Result** @ResultZero - %27 = call i1 @__quantum__rt__result_equal(%Result* %25, %Result* %26) - %28 = xor i1 %27, true - br i1 %28, label %then0__2, label %continue__2 - -then0__2: ; preds = %else__1 - store i64 2, i64* %res - br label %continue__2 - -continue__2: ; preds = %then0__2, %else__1 - %29 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls, i64 0) - %30 = bitcast i8* %29 to %Qubit** - %qb__inline__3 = load %Qubit*, %Qubit** %30 - call void @__quantum__qis__h__body(%Qubit* %qb__inline__3) - %31 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls, i64 1) - %32 = bitcast i8* %31 to %Qubit** - %qb__inline__4 = load %Qubit*, %Qubit** %32 - call void @__quantum__qis__h__body(%Qubit* %qb__inline__4) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %15, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %15, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %16, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %20, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %20, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %21, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %25, i64 -1) - br label %continue__1 - -continue__1: ; preds = %continue__2, %then0__1 - call void @__quantum__rt__qubit_release(%Qubit* %target) - call void @__quantum__rt__qubit_release_array(%Array* %ctls) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %0, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %3, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %3, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %4, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %7, i64 -1) - %33 = load i64, i64* %res - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %op, i64 -1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %op, i64 -1) - ret i64 %33 -} - -declare void @__quantum__rt__callable_memory_management(i32, %Callable*, i64) - -declare void @__quantum__rt__callable_update_alias_count(%Callable*, i64) - -declare %Qubit* @__quantum__rt__qubit_allocate() - -declare %Array* @__quantum__rt__qubit_allocate_array(i64) - -declare void @__quantum__rt__callable_invoke(%Callable*, %Tuple*, %Tuple*) - -declare %Callable* @__quantum__rt__callable_copy(%Callable*, i1) - -declare void @__quantum__rt__callable_make_adjoint(%Callable*) - -declare i1 @__quantum__rt__result_equal(%Result*, %Result*) - -declare void @__quantum__rt__callable_make_controlled(%Callable*) - -declare void @__quantum__rt__callable_update_reference_count(%Callable*, i64) - -declare void @__quantum__rt__result_update_reference_count(%Result*, i64) - -declare void @__quantum__rt__qubit_release(%Qubit*) - -declare void @__quantum__rt__qubit_release_array(%Array*) - -define i64 @Microsoft__Quantum__Testing__QIR__Test_Simulator_QIS__body() #0 { -entry: - %res = alloca i64 - store i64 0, i64* %res - %0 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__X, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %1 = call i64 @Microsoft__Quantum__Testing__QIR__InvokeAllVariants__body(%Callable* %0) - store i64 %1, i64* %res - %2 = icmp ne i64 %1, 0 - br i1 %2, label %then0__1, label %continue__1 - -then0__1: ; preds = %entry - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %0, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %0, i64 -1) - ret i64 %1 - -continue__1: ; preds = %entry - %3 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__Y, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %4 = call i64 @Microsoft__Quantum__Testing__QIR__InvokeAllVariants__body(%Callable* %3) - store i64 %4, i64* %res - %5 = icmp ne i64 %4, 0 - br i1 %5, label %then0__2, label %continue__2 - -then0__2: ; preds = %continue__1 - %6 = add i64 10, %4 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %0, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %0, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %3, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %3, i64 -1) - ret i64 %6 - -continue__2: ; preds = %continue__1 - %7 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__Z, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %8 = call i64 @Microsoft__Quantum__Testing__QIR__InvokeAllVariants__body(%Callable* %7) - store i64 %8, i64* %res - %9 = icmp ne i64 %8, 0 - br i1 %9, label %then0__3, label %continue__3 - -then0__3: ; preds = %continue__2 - %10 = add i64 20, %8 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %0, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %0, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %3, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %3, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %7, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %7, i64 -1) - ret i64 %10 - -continue__3: ; preds = %continue__2 - %11 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__H, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %12 = call i64 @Microsoft__Quantum__Testing__QIR__InvokeAllVariants__body(%Callable* %11) - store i64 %12, i64* %res - %13 = icmp ne i64 %12, 0 - br i1 %13, label %then0__4, label %continue__4 - -then0__4: ; preds = %continue__3 - %14 = add i64 30, %12 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %0, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %0, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %3, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %3, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %7, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %7, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %11, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %11, i64 -1) - ret i64 %14 - -continue__4: ; preds = %continue__3 - %15 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__S, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %16 = call i64 @Microsoft__Quantum__Testing__QIR__InvokeAllVariants__body(%Callable* %15) - store i64 %16, i64* %res - %17 = icmp ne i64 %16, 0 - br i1 %17, label %then0__5, label %continue__5 - -then0__5: ; preds = %continue__4 - %18 = add i64 40, %16 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %0, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %0, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %3, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %3, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %7, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %7, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %11, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %11, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %15, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %15, i64 -1) - ret i64 %18 - -continue__5: ; preds = %continue__4 - %19 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__T, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %20 = call i64 @Microsoft__Quantum__Testing__QIR__InvokeAllVariants__body(%Callable* %19) - store i64 %20, i64* %res - %21 = icmp ne i64 %20, 0 - br i1 %21, label %then0__6, label %continue__6 - -then0__6: ; preds = %continue__5 - %22 = add i64 50, %20 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %0, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %0, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %3, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %3, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %7, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %7, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %11, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %11, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %15, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %15, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %19, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %19, i64 -1) - ret i64 %22 - -continue__6: ; preds = %continue__5 - %23 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint ({ %Callable*, i2, double }* getelementptr ({ %Callable*, i2, double }, { %Callable*, i2, double }* null, i32 1) to i64)) - %24 = bitcast %Tuple* %23 to { %Callable*, i2, double }* - %25 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %24, i64 0, i32 0 - %26 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %24, i64 0, i32 1 - %27 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %24, i64 0, i32 2 - %28 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__R, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %29 = load i2, i2* @PauliX - store %Callable* %28, %Callable** %25 - store i2 %29, i2* %26 - store double 4.200000e-01, double* %27 - %30 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @PartialApplication__1, [2 x void (%Tuple*, i64)*]* @MemoryManagement__1, %Tuple* %23) - %31 = call i64 @Microsoft__Quantum__Testing__QIR__InvokeAllVariants__body(%Callable* %30) - store i64 %31, i64* %res - %32 = icmp ne i64 %31, 0 - br i1 %32, label %then0__7, label %continue__7 - -then0__7: ; preds = %continue__6 - %33 = add i64 60, %31 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %0, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %0, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %3, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %3, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %7, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %7, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %11, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %11, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %15, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %15, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %19, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %19, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %30, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %30, i64 -1) - ret i64 %33 - -continue__7: ; preds = %continue__6 - %targets = call %Array* @__quantum__rt__qubit_allocate_array(i64 2) - call void @__quantum__rt__array_update_alias_count(%Array* %targets, i64 1) - %ctls = call %Array* @__quantum__rt__qubit_allocate_array(i64 2) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %paulis__inline__1 = call %Array* @__quantum__rt__array_create_1d(i32 1, i64 2) - %34 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis__inline__1, i64 0) - %35 = bitcast i8* %34 to i2* - %36 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis__inline__1, i64 1) - %37 = bitcast i8* %36 to i2* - %38 = load i2, i2* @PauliX - %39 = load i2, i2* @PauliY - store i2 %38, i2* %35 - store i2 %39, i2* %37 - call void @__quantum__rt__array_update_alias_count(%Array* %paulis__inline__1, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %targets, i64 1) - call void @__quantum__qis__exp__body(%Array* %paulis__inline__1, double 4.200000e-01, %Array* %targets) - call void @__quantum__rt__array_update_alias_count(%Array* %paulis__inline__1, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %targets, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %paulis__inline__1, i64 -1) - %paulis__inline__2 = call %Array* @__quantum__rt__array_create_1d(i32 1, i64 2) - %40 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis__inline__2, i64 0) - %41 = bitcast i8* %40 to i2* - %42 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis__inline__2, i64 1) - %43 = bitcast i8* %42 to i2* - %44 = load i2, i2* @PauliX - %45 = load i2, i2* @PauliY - store i2 %44, i2* %41 - store i2 %45, i2* %43 - call void @__quantum__rt__array_update_alias_count(%Array* %paulis__inline__2, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %targets, i64 1) - call void @__quantum__qis__exp__adj(%Array* %paulis__inline__2, double 4.200000e-01, %Array* %targets) - call void @__quantum__rt__array_update_alias_count(%Array* %paulis__inline__2, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %targets, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %paulis__inline__2, i64 -1) - %46 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %targets, i64 0) - %47 = bitcast i8* %46 to %Qubit** - %48 = load %Qubit*, %Qubit** %47 - %49 = call %Result* @Microsoft__Quantum__Intrinsic__M__body(%Qubit* %48) - %50 = load %Result*, %Result** @ResultZero - %51 = call i1 @__quantum__rt__result_equal(%Result* %49, %Result* %50) - %52 = xor i1 %51, true - %53 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %targets, i64 1) - %54 = bitcast i8* %53 to %Qubit** - %55 = load %Qubit*, %Qubit** %54 - %56 = call %Result* @Microsoft__Quantum__Intrinsic__M__body(%Qubit* %55) - %57 = load %Result*, %Result** @ResultZero - %58 = call i1 @__quantum__rt__result_equal(%Result* %56, %Result* %57) - %59 = xor i1 %58, true - %60 = or i1 %52, %59 - br i1 %60, label %then0__8, label %else__1 - -then0__8: ; preds = %continue__7 - store i64 1, i64* %res - br label %continue__8 - -else__1: ; preds = %continue__7 - %61 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls, i64 0) - %62 = bitcast i8* %61 to %Qubit** - %qb__inline__3 = load %Qubit*, %Qubit** %62 - call void @__quantum__qis__h__body(%Qubit* %qb__inline__3) - %63 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls, i64 1) - %64 = bitcast i8* %63 to %Qubit** - %qb__inline__4 = load %Qubit*, %Qubit** %64 - call void @__quantum__qis__h__body(%Qubit* %qb__inline__4) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %paulis__inline__5 = call %Array* @__quantum__rt__array_create_1d(i32 1, i64 2) - %65 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis__inline__5, i64 0) - %66 = bitcast i8* %65 to i2* - %67 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis__inline__5, i64 1) - %68 = bitcast i8* %67 to i2* - %69 = load i2, i2* @PauliX - %70 = load i2, i2* @PauliY - store i2 %69, i2* %66 - store i2 %70, i2* %68 - call void @__quantum__rt__array_update_alias_count(%Array* %paulis__inline__5, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %targets, i64 1) - %71 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint ({ %Array*, double, %Array* }* getelementptr ({ %Array*, double, %Array* }, { %Array*, double, %Array* }* null, i32 1) to i64)) - %72 = bitcast %Tuple* %71 to { %Array*, double, %Array* }* - %73 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %72, i64 0, i32 0 - %74 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %72, i64 0, i32 1 - %75 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %72, i64 0, i32 2 - store %Array* %paulis__inline__5, %Array** %73 - store double 4.200000e-01, double* %74 - store %Array* %targets, %Array** %75 - call void @__quantum__qis__exp__ctl(%Array* %ctls, { %Array*, double, %Array* }* %72) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %paulis__inline__5, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %targets, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %paulis__inline__5, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %71, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %paulis__inline__6 = call %Array* @__quantum__rt__array_create_1d(i32 1, i64 2) - %76 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis__inline__6, i64 0) - %77 = bitcast i8* %76 to i2* - %78 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis__inline__6, i64 1) - %79 = bitcast i8* %78 to i2* - %80 = load i2, i2* @PauliX - %81 = load i2, i2* @PauliY - store i2 %80, i2* %77 - store i2 %81, i2* %79 - call void @__quantum__rt__array_update_alias_count(%Array* %paulis__inline__6, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %targets, i64 1) - %82 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint ({ %Array*, double, %Array* }* getelementptr ({ %Array*, double, %Array* }, { %Array*, double, %Array* }* null, i32 1) to i64)) - %83 = bitcast %Tuple* %82 to { %Array*, double, %Array* }* - %84 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %83, i64 0, i32 0 - %85 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %83, i64 0, i32 1 - %86 = getelementptr { %Array*, double, %Array* }, { %Array*, double, %Array* }* %83, i64 0, i32 2 - store %Array* %paulis__inline__6, %Array** %84 - store double 4.200000e-01, double* %85 - store %Array* %targets, %Array** %86 - call void @__quantum__qis__exp__ctladj(%Array* %ctls, { %Array*, double, %Array* }* %83) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %paulis__inline__6, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %targets, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %paulis__inline__6, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %82, i64 -1) - %87 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls, i64 0) - %88 = bitcast i8* %87 to %Qubit** - %qb__inline__7 = load %Qubit*, %Qubit** %88 - call void @__quantum__qis__h__body(%Qubit* %qb__inline__7) - %89 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls, i64 1) - %90 = bitcast i8* %89 to %Qubit** - %qb__inline__8 = load %Qubit*, %Qubit** %90 - call void @__quantum__qis__h__body(%Qubit* %qb__inline__8) - %91 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %targets, i64 0) - %92 = bitcast i8* %91 to %Qubit** - %93 = load %Qubit*, %Qubit** %92 - %94 = call %Result* @Microsoft__Quantum__Intrinsic__M__body(%Qubit* %93) - %95 = load %Result*, %Result** @ResultZero - %96 = call i1 @__quantum__rt__result_equal(%Result* %94, %Result* %95) - %97 = xor i1 %96, true - %98 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %targets, i64 1) - %99 = bitcast i8* %98 to %Qubit** - %100 = load %Qubit*, %Qubit** %99 - %101 = call %Result* @Microsoft__Quantum__Intrinsic__M__body(%Qubit* %100) - %102 = load %Result*, %Result** @ResultZero - %103 = call i1 @__quantum__rt__result_equal(%Result* %101, %Result* %102) - %104 = xor i1 %103, true - %105 = or i1 %97, %104 - br i1 %105, label %then0__9, label %continue__9 - -then0__9: ; preds = %else__1 - store i64 72, i64* %res - br label %continue__9 - -continue__9: ; preds = %then0__9, %else__1 - call void @__quantum__rt__result_update_reference_count(%Result* %94, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %101, i64 -1) - br label %continue__8 - -continue__8: ; preds = %continue__9, %then0__8 - call void @__quantum__rt__qubit_release_array(%Array* %targets) - call void @__quantum__rt__qubit_release_array(%Array* %ctls) - call void @__quantum__rt__array_update_alias_count(%Array* %targets, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %targets, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %49, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %56, i64 -1) - %106 = load i64, i64* %res - %107 = icmp ne i64 %106, 0 - br i1 %107, label %then0__10, label %continue__10 - -then0__10: ; preds = %continue__8 - %108 = add i64 70, %106 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %0, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %0, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %3, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %3, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %7, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %7, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %11, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %11, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %15, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %15, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %19, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %19, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %30, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %30, i64 -1) - ret i64 %108 - -continue__10: ; preds = %continue__8 - %qs = call %Array* @__quantum__rt__qubit_allocate_array(i64 3) - call void @__quantum__rt__array_update_alias_count(%Array* %qs, i64 1) - %109 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %110 = bitcast i8* %109 to %Qubit** - %qb__inline__9 = load %Qubit*, %Qubit** %110 - call void @__quantum__qis__h__body(%Qubit* %qb__inline__9) - %111 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %112 = bitcast i8* %111 to %Qubit** - %qb__inline__10 = load %Qubit*, %Qubit** %112 - call void @__quantum__qis__h__body(%Qubit* %qb__inline__10) - %bases__inline__11 = call %Array* @__quantum__rt__array_create_1d(i32 1, i64 3) - %113 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %bases__inline__11, i64 0) - %114 = bitcast i8* %113 to i2* - %115 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %bases__inline__11, i64 1) - %116 = bitcast i8* %115 to i2* - %117 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %bases__inline__11, i64 2) - %118 = bitcast i8* %117 to i2* - %119 = load i2, i2* @PauliX - %120 = load i2, i2* @PauliZ - %121 = load i2, i2* @PauliX - store i2 %119, i2* %114 - store i2 %120, i2* %116 - store i2 %121, i2* %118 - call void @__quantum__rt__array_update_alias_count(%Array* %bases__inline__11, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %qs, i64 1) - %122 = call %Result* @__quantum__qis__measure__body(%Array* %bases__inline__11, %Array* %qs) - call void @__quantum__rt__array_update_alias_count(%Array* %bases__inline__11, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qs, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %bases__inline__11, i64 -1) - %123 = load %Result*, %Result** @ResultZero - %124 = call i1 @__quantum__rt__result_equal(%Result* %122, %Result* %123) - %125 = xor i1 %124, true - br i1 %125, label %then0__11, label %continue__11 - -then0__11: ; preds = %continue__10 - store i64 80, i64* %res - br label %continue__11 - -continue__11: ; preds = %then0__11, %continue__10 - %126 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %127 = bitcast i8* %126 to %Qubit** - %qb__inline__12 = load %Qubit*, %Qubit** %127 - call void @__quantum__qis__h__body(%Qubit* %qb__inline__12) - %128 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %129 = bitcast i8* %128 to %Qubit** - %qb__inline__13 = load %Qubit*, %Qubit** %129 - call void @__quantum__qis__h__body(%Qubit* %qb__inline__13) - call void @__quantum__rt__qubit_release_array(%Array* %qs) - call void @__quantum__rt__array_update_alias_count(%Array* %qs, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %qs, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %122, i64 -1) - %130 = load i64, i64* %res - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %0, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %0, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %3, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %3, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %7, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %7, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %11, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %11, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %15, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %15, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %19, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %19, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %30, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %30, i64 -1) - ret i64 %130 -} - -define void @Microsoft__Quantum__Intrinsic__X__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr { %Qubit* }, { %Qubit* }* %0, i64 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__X__body(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr { %Qubit* }, { %Qubit* }* %0, i64 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__X__adj(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__X__ctl(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__X__ctladj(%Array* %3, %Qubit* %4) - ret void -} - -declare %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]*, [2 x void (%Tuple*, i64)*]*, %Tuple*) - -define void @Microsoft__Quantum__Intrinsic__Y__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr { %Qubit* }, { %Qubit* }* %0, i64 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__Y__body(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr { %Qubit* }, { %Qubit* }* %0, i64 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__Y__adj(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__Y__ctl(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__Y__ctladj(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr { %Qubit* }, { %Qubit* }* %0, i64 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__Z__body(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr { %Qubit* }, { %Qubit* }* %0, i64 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__Z__adj(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__Z__ctl(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__Z__ctladj(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__H__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr { %Qubit* }, { %Qubit* }* %0, i64 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__H__body(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__H__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr { %Qubit* }, { %Qubit* }* %0, i64 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__H__adj(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__H__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__H__ctl(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__H__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__H__ctladj(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr { %Qubit* }, { %Qubit* }* %0, i64 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__S__body(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr { %Qubit* }, { %Qubit* }* %0, i64 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__S__adj(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__S__ctl(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__S__ctladj(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__T__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr { %Qubit* }, { %Qubit* }* %0, i64 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__T__body(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__T__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr { %Qubit* }, { %Qubit* }* %0, i64 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__T__adj(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__T__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__T__ctl(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__T__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__T__ctladj(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__R__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { i2, double, %Qubit* }* - %1 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %0, i64 0, i32 1 - %3 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %0, i64 0, i32 2 - %4 = load i2, i2* %1 - %5 = load double, double* %2 - %6 = load %Qubit*, %Qubit** %3 - call void @Microsoft__Quantum__Intrinsic__R__body(i2 %4, double %5, %Qubit* %6) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__R__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { i2, double, %Qubit* }* - %1 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %0, i64 0, i32 1 - %3 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %0, i64 0, i32 2 - %4 = load i2, i2* %1 - %5 = load double, double* %2 - %6 = load %Qubit*, %Qubit** %3 - call void @Microsoft__Quantum__Intrinsic__R__adj(i2 %4, double %5, %Qubit* %6) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__R__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, { i2, double, %Qubit* }* }* - %1 = getelementptr { %Array*, { i2, double, %Qubit* }* }, { %Array*, { i2, double, %Qubit* }* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, { i2, double, %Qubit* }* }, { %Array*, { i2, double, %Qubit* }* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load { i2, double, %Qubit* }*, { i2, double, %Qubit* }** %2 - call void @Microsoft__Quantum__Intrinsic__R__ctl(%Array* %3, { i2, double, %Qubit* }* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__R__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, { i2, double, %Qubit* }* }* - %1 = getelementptr { %Array*, { i2, double, %Qubit* }* }, { %Array*, { i2, double, %Qubit* }* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, { i2, double, %Qubit* }* }, { %Array*, { i2, double, %Qubit* }* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load { i2, double, %Qubit* }*, { i2, double, %Qubit* }** %2 - call void @Microsoft__Quantum__Intrinsic__R__ctladj(%Array* %3, { i2, double, %Qubit* }* %4) - ret void -} - -define void @Lifted__PartialApplication__1__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, i2, double }* - %1 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %0, i64 0, i32 1 - %2 = load i2, i2* %1 - %3 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %0, i64 0, i32 2 - %4 = load double, double* %3 - %5 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %6 = getelementptr { %Qubit* }, { %Qubit* }* %5, i64 0, i32 0 - %7 = load %Qubit*, %Qubit** %6 - %8 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint ({ i2, double, %Qubit* }* getelementptr ({ i2, double, %Qubit* }, { i2, double, %Qubit* }* null, i32 1) to i64)) - %9 = bitcast %Tuple* %8 to { i2, double, %Qubit* }* - %10 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %9, i64 0, i32 0 - %11 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %9, i64 0, i32 1 - %12 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %9, i64 0, i32 2 - store i2 %2, i2* %10 - store double %4, double* %11 - store %Qubit* %7, %Qubit** %12 - %13 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %0, i64 0, i32 0 - %14 = load %Callable*, %Callable** %13 - call void @__quantum__rt__callable_invoke(%Callable* %14, %Tuple* %8, %Tuple* %result-tuple) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %8, i64 -1) - ret void -} - -define void @Lifted__PartialApplication__1__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, i2, double }* - %1 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %0, i64 0, i32 1 - %2 = load i2, i2* %1 - %3 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %0, i64 0, i32 2 - %4 = load double, double* %3 - %5 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %6 = getelementptr { %Qubit* }, { %Qubit* }* %5, i64 0, i32 0 - %7 = load %Qubit*, %Qubit** %6 - %8 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint ({ i2, double, %Qubit* }* getelementptr ({ i2, double, %Qubit* }, { i2, double, %Qubit* }* null, i32 1) to i64)) - %9 = bitcast %Tuple* %8 to { i2, double, %Qubit* }* - %10 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %9, i64 0, i32 0 - %11 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %9, i64 0, i32 1 - %12 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %9, i64 0, i32 2 - store i2 %2, i2* %10 - store double %4, double* %11 - store %Qubit* %7, %Qubit** %12 - %13 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %0, i64 0, i32 0 - %14 = load %Callable*, %Callable** %13 - %15 = call %Callable* @__quantum__rt__callable_copy(%Callable* %14, i1 false) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %15, i64 1) - call void @__quantum__rt__callable_make_adjoint(%Callable* %15) - call void @__quantum__rt__callable_invoke(%Callable* %15, %Tuple* %8, %Tuple* %result-tuple) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %8, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %15, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %15, i64 -1) - ret void -} - -define void @Lifted__PartialApplication__1__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - %5 = bitcast %Tuple* %capture-tuple to { %Callable*, i2, double }* - %6 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %5, i64 0, i32 1 - %7 = load i2, i2* %6 - %8 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %5, i64 0, i32 2 - %9 = load double, double* %8 - %10 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint ({ i2, double, %Qubit* }* getelementptr ({ i2, double, %Qubit* }, { i2, double, %Qubit* }* null, i32 1) to i64)) - %11 = bitcast %Tuple* %10 to { i2, double, %Qubit* }* - %12 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %11, i64 0, i32 0 - %13 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %11, i64 0, i32 1 - %14 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %11, i64 0, i32 2 - store i2 %7, i2* %12 - store double %9, double* %13 - store %Qubit* %4, %Qubit** %14 - %15 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 2)) - %16 = bitcast %Tuple* %15 to { %Array*, { i2, double, %Qubit* }* }* - %17 = getelementptr { %Array*, { i2, double, %Qubit* }* }, { %Array*, { i2, double, %Qubit* }* }* %16, i64 0, i32 0 - %18 = getelementptr { %Array*, { i2, double, %Qubit* }* }, { %Array*, { i2, double, %Qubit* }* }* %16, i64 0, i32 1 - store %Array* %3, %Array** %17 - store { i2, double, %Qubit* }* %11, { i2, double, %Qubit* }** %18 - %19 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %5, i64 0, i32 0 - %20 = load %Callable*, %Callable** %19 - %21 = call %Callable* @__quantum__rt__callable_copy(%Callable* %20, i1 false) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %21, i64 1) - call void @__quantum__rt__callable_make_controlled(%Callable* %21) - call void @__quantum__rt__callable_invoke(%Callable* %21, %Tuple* %15, %Tuple* %result-tuple) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %10, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %15, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %21, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %21, i64 -1) - ret void -} - -define void @Lifted__PartialApplication__1__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 0 - %2 = getelementptr { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i64 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - %5 = bitcast %Tuple* %capture-tuple to { %Callable*, i2, double }* - %6 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %5, i64 0, i32 1 - %7 = load i2, i2* %6 - %8 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %5, i64 0, i32 2 - %9 = load double, double* %8 - %10 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint ({ i2, double, %Qubit* }* getelementptr ({ i2, double, %Qubit* }, { i2, double, %Qubit* }* null, i32 1) to i64)) - %11 = bitcast %Tuple* %10 to { i2, double, %Qubit* }* - %12 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %11, i64 0, i32 0 - %13 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %11, i64 0, i32 1 - %14 = getelementptr { i2, double, %Qubit* }, { i2, double, %Qubit* }* %11, i64 0, i32 2 - store i2 %7, i2* %12 - store double %9, double* %13 - store %Qubit* %4, %Qubit** %14 - %15 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 2)) - %16 = bitcast %Tuple* %15 to { %Array*, { i2, double, %Qubit* }* }* - %17 = getelementptr { %Array*, { i2, double, %Qubit* }* }, { %Array*, { i2, double, %Qubit* }* }* %16, i64 0, i32 0 - %18 = getelementptr { %Array*, { i2, double, %Qubit* }* }, { %Array*, { i2, double, %Qubit* }* }* %16, i64 0, i32 1 - store %Array* %3, %Array** %17 - store { i2, double, %Qubit* }* %11, { i2, double, %Qubit* }** %18 - %19 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %5, i64 0, i32 0 - %20 = load %Callable*, %Callable** %19 - %21 = call %Callable* @__quantum__rt__callable_copy(%Callable* %20, i1 false) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %21, i64 1) - call void @__quantum__rt__callable_make_adjoint(%Callable* %21) - call void @__quantum__rt__callable_make_controlled(%Callable* %21) - call void @__quantum__rt__callable_invoke(%Callable* %21, %Tuple* %15, %Tuple* %result-tuple) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %10, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %15, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %21, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %21, i64 -1) - ret void -} - -define void @MemoryManagement__1__RefCount(%Tuple* %capture-tuple, i64 %count-change) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, i2, double }* - %1 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %0, i64 0, i32 0 - %2 = load %Callable*, %Callable** %1 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %2, i64 %count-change) - call void @__quantum__rt__callable_update_reference_count(%Callable* %2, i64 %count-change) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %capture-tuple, i64 %count-change) - ret void -} - -define void @MemoryManagement__1__AliasCount(%Tuple* %capture-tuple, i64 %count-change) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, i2, double }* - %1 = getelementptr { %Callable*, i2, double }, { %Callable*, i2, double }* %0, i64 0, i32 0 - %2 = load %Callable*, %Callable** %1 - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %2, i64 %count-change) - call void @__quantum__rt__callable_update_alias_count(%Callable* %2, i64 %count-change) - call void @__quantum__rt__tuple_update_alias_count(%Tuple* %capture-tuple, i64 %count-change) - ret void -} - -declare void @__quantum__rt__tuple_update_alias_count(%Tuple*, i64) - -attributes #0 = { "EntryPoint" } diff --git a/src/QirRuntime/test/FullstateSimulator/qsharp/qir-test-simulator.csproj b/src/QirRuntime/test/FullstateSimulator/qsharp/qir-test-simulator.csproj new file mode 100644 index 00000000000..5166db5e375 --- /dev/null +++ b/src/QirRuntime/test/FullstateSimulator/qsharp/qir-test-simulator.csproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp3.1 + True + false + + + + + + + diff --git a/src/QirRuntime/test/FullstateSimulator/qir-test-simulator.qs b/src/QirRuntime/test/FullstateSimulator/qsharp/qir-test-simulator.qs similarity index 67% rename from src/QirRuntime/test/FullstateSimulator/qir-test-simulator.qs rename to src/QirRuntime/test/FullstateSimulator/qsharp/qir-test-simulator.qs index b32c6bed364..bb97857e50c 100644 --- a/src/QirRuntime/test/FullstateSimulator/qir-test-simulator.qs +++ b/src/QirRuntime/test/FullstateSimulator/qsharp/qir-test-simulator.qs @@ -10,20 +10,23 @@ namespace Microsoft.Quantum.Testing.QIR operation InvokeAllVariants(op : (Qubit => Unit is Adj + Ctl)) : Int { mutable res = 0; - using((target, ctls) = (Qubit(), Qubit[2])) + use (target, ctls) = (Qubit(), Qubit[2]) { op(target); Adjoint op(target); - if (M(target) != Zero) { let res = 1; } + if (M(target) != Zero) { set res = 1; } else { H(ctls[0]); H(ctls[1]); Controlled op(ctls, target); Adjoint Controlled op(ctls, target); - if (M(target) != Zero) { return 2; } - H(ctls[0]); - H(ctls[1]); + if (M(target) != Zero) { set res = 2; } + else + { + H(ctls[0]); + H(ctls[1]); + } } } return res; @@ -33,33 +36,33 @@ namespace Microsoft.Quantum.Testing.QIR operation Test_Simulator_QIS() : Int { mutable res = 0; - let res = InvokeAllVariants(X); + set res = InvokeAllVariants(X); if (res != 0) { return res; } - let res = InvokeAllVariants(Y); + set res = InvokeAllVariants(Y); if (res != 0) { return 10 + res; } - let res = InvokeAllVariants(Z); + set res = InvokeAllVariants(Z); if (res != 0) { return 20 + res; } - let res = InvokeAllVariants(H); + set res = InvokeAllVariants(H); if (res != 0) { return 30 + res; } - let res = InvokeAllVariants(S); + set res = InvokeAllVariants(S); if (res != 0) { return 40 + res; } - let res = InvokeAllVariants(T); + set res = InvokeAllVariants(T); if (res != 0) { return 50 + res; } - let res = InvokeAllVariants(R(PauliX, 0.42, _)); + set res = InvokeAllVariants(R(PauliX, 0.42, _)); if (res != 0) { return 60 + res; } - using((targets, ctls) = (Qubit[2], Qubit[2])) + use (targets, ctls) = (Qubit[2], Qubit[2]) { let theta = 0.42; Exp([PauliX, PauliY], theta, targets); Adjoint Exp([PauliX, PauliY], theta, targets); - if (M(target) != Zero) { let res = 1; } + if (M(targets[0]) != Zero) { set res = 1; } H(ctls[0]); H(ctls[1]); @@ -67,15 +70,15 @@ namespace Microsoft.Quantum.Testing.QIR Adjoint Controlled Exp(ctls, ([PauliX, PauliY], theta, targets)); H(ctls[0]); H(ctls[1]); - if (M(target) != Zero) { let res = 70 + 2; } + if (M(targets[0]) != Zero) { set res = 2; } } if (res != 0) { return 70 + res; } - using (qs = Qubit[3]) + use qs = Qubit[3] { H(qs[0]); H(qs[2]); - if (Measure([PauliX, PauliZ, PauliX], qs) != zero) { let res = 80; } + if (Measure([PauliX, PauliZ, PauliX], qs) != Zero) { set res = 80; } } return res; } diff --git a/src/QirRuntime/test/QIR-dynamic/CMakeLists.txt b/src/QirRuntime/test/QIR-dynamic/CMakeLists.txt index d40bcbd8871..ffdbcaeed53 100644 --- a/src/QirRuntime/test/QIR-dynamic/CMakeLists.txt +++ b/src/QirRuntime/test/QIR-dynamic/CMakeLists.txt @@ -1,12 +1,6 @@ -if (WIN32) - set(TEST_FILES - qir-test-random-win - ) -else() - set(TEST_FILES - qir-test-random-lnx - ) -endif() +set(TEST_FILES + qir-test-random +) foreach(file ${TEST_FILES}) compile_from_qir(${file} "") # don't create a target per file diff --git a/src/QirRuntime/test/QIR-dynamic/qir-test-random-lnx.ll b/src/QirRuntime/test/QIR-dynamic/qir-test-random-lnx.ll deleted file mode 100644 index cccc97ec31d..00000000000 --- a/src/QirRuntime/test/QIR-dynamic/qir-test-random-lnx.ll +++ /dev/null @@ -1,142 +0,0 @@ - -%Result = type opaque -%Range = type { i64, i64, i64 } -%Qubit = type opaque -%Array = type opaque - -@ResultZero = external global %Result* -@ResultOne = external global %Result* -@PauliI = constant i2 0 -@PauliX = constant i2 1 -@PauliY = constant i2 -1 -@PauliZ = constant i2 -2 -@EmptyRange = internal constant %Range { i64 0, i64 1, i64 -1 } - -@Microsoft__Quantum__Testing__QIR__QuantumRandomNumberGenerator = alias i64 (), i64 ()* @Microsoft__Quantum__Testing__QIR__QuantumRandomNumberGenerator__body - -define %Result* @Microsoft__Quantum__Intrinsic__M__body(%Qubit* %qb) { -entry: - %bases__inline__1 = call %Array* @__quantum__rt__array_create_1d(i32 1, i64 1) - %0 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %bases__inline__1, i64 0) - %1 = bitcast i8* %0 to i2* - %2 = load i2, i2* @PauliZ - store i2 %2, i2* %1 - call void @__quantum__rt__array_update_alias_count(%Array* %bases__inline__1, i64 1) - %qubits__inline__1 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %3 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qubits__inline__1, i64 0) - %4 = bitcast i8* %3 to %Qubit** - store %Qubit* %qb, %Qubit** %4 - call void @__quantum__rt__array_update_alias_count(%Array* %qubits__inline__1, i64 1) - %5 = call %Result* @__quantum__qis__measure__body(%Array* %bases__inline__1, %Array* %qubits__inline__1) - call void @__quantum__rt__array_update_alias_count(%Array* %bases__inline__1, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits__inline__1, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %bases__inline__1, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %qubits__inline__1, i64 -1) - ret %Result* %5 -} - -declare %Array* @__quantum__rt__array_create_1d(i32, i64) - -declare i8* @__quantum__rt__array_get_element_ptr_1d(%Array*, i64) - -declare void @__quantum__rt__array_update_alias_count(%Array*, i64) - -declare %Result* @__quantum__qis__measure__body(%Array*, %Array*) - -declare void @__quantum__rt__array_update_reference_count(%Array*, i64) - -define %Result* @Microsoft__Quantum__Intrinsic__Measure__body(%Array* %bases, %Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %bases, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %0 = call %Result* @__quantum__qis__measure__body(%Array* %bases, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %bases, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret %Result* %0 -} - -define void @Microsoft__Quantum__Intrinsic__H__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__h__body(%Qubit* %qb) - ret void -} - -declare void @__quantum__qis__h__body(%Qubit*) - -define void @Microsoft__Quantum__Intrinsic__H__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__h__body(%Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__H__ctl(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__h__ctl(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -declare void @__quantum__qis__h__ctl(%Array*, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__H__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__h__ctl(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -define i64 @Microsoft__Quantum__Testing__QIR__QuantumRandomNumberGenerator__body() #0 { -entry: - %randomNumber = alloca i64 - store i64 0, i64* %randomNumber - br label %header__1 - -header__1: ; preds = %exiting__1, %entry - %i = phi i64 [ 1, %entry ], [ %8, %exiting__1 ] - %0 = icmp sle i64 %i, 64 - br i1 %0, label %body__1, label %exit__1 - -body__1: ; preds = %header__1 - %q = call %Qubit* @__quantum__rt__qubit_allocate() - call void @__quantum__qis__h__body(%Qubit* %q) - %1 = load i64, i64* %randomNumber - %2 = shl i64 %1, 1 - store i64 %2, i64* %randomNumber - %3 = call %Result* @Microsoft__Quantum__Intrinsic__M__body(%Qubit* %q) - %4 = load %Result*, %Result** @ResultOne - %5 = call i1 @__quantum__rt__result_equal(%Result* %3, %Result* %4) - br i1 %5, label %then0__1, label %continue__1 - -then0__1: ; preds = %body__1 - %6 = load i64, i64* %randomNumber - %7 = add i64 %6, 1 - store i64 %7, i64* %randomNumber - br label %continue__1 - -continue__1: ; preds = %then0__1, %body__1 - call void @__quantum__rt__qubit_release(%Qubit* %q) - call void @__quantum__rt__result_update_reference_count(%Result* %3, i64 -1) - br label %exiting__1 - -exiting__1: ; preds = %continue__1 - %8 = add i64 %i, 1 - br label %header__1 - -exit__1: ; preds = %header__1 - %9 = load i64, i64* %randomNumber - ret i64 %9 -} - -declare %Qubit* @__quantum__rt__qubit_allocate() - -declare %Array* @__quantum__rt__qubit_allocate_array(i64) - -declare i1 @__quantum__rt__result_equal(%Result*, %Result*) - -declare void @__quantum__rt__qubit_release(%Qubit*) - -declare void @__quantum__rt__result_update_reference_count(%Result*, i64) - -attributes #0 = { "EntryPoint" } diff --git a/src/QirRuntime/test/QIR-dynamic/qir-test-random-win.ll b/src/QirRuntime/test/QIR-dynamic/qir-test-random-win.ll deleted file mode 100644 index d83a3f082e4..00000000000 --- a/src/QirRuntime/test/QIR-dynamic/qir-test-random-win.ll +++ /dev/null @@ -1,142 +0,0 @@ - -%Result = type opaque -%Range = type { i64, i64, i64 } -%Qubit = type opaque -%Array = type opaque - -@ResultZero = external dllimport global %Result* -@ResultOne = external dllimport global %Result* -@PauliI = constant i2 0 -@PauliX = constant i2 1 -@PauliY = constant i2 -1 -@PauliZ = constant i2 -2 -@EmptyRange = internal constant %Range { i64 0, i64 1, i64 -1 } - -@Microsoft__Quantum__Testing__QIR__QuantumRandomNumberGenerator = alias i64 (), i64 ()* @Microsoft__Quantum__Testing__QIR__QuantumRandomNumberGenerator__body - -define %Result* @Microsoft__Quantum__Intrinsic__M__body(%Qubit* %qb) { -entry: - %bases__inline__1 = call %Array* @__quantum__rt__array_create_1d(i32 1, i64 1) - %0 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %bases__inline__1, i64 0) - %1 = bitcast i8* %0 to i2* - %2 = load i2, i2* @PauliZ - store i2 %2, i2* %1 - call void @__quantum__rt__array_update_alias_count(%Array* %bases__inline__1, i64 1) - %qubits__inline__1 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %3 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qubits__inline__1, i64 0) - %4 = bitcast i8* %3 to %Qubit** - store %Qubit* %qb, %Qubit** %4 - call void @__quantum__rt__array_update_alias_count(%Array* %qubits__inline__1, i64 1) - %5 = call %Result* @__quantum__qis__measure__body(%Array* %bases__inline__1, %Array* %qubits__inline__1) - call void @__quantum__rt__array_update_alias_count(%Array* %bases__inline__1, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits__inline__1, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %bases__inline__1, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %qubits__inline__1, i64 -1) - ret %Result* %5 -} - -declare %Array* @__quantum__rt__array_create_1d(i32, i64) - -declare i8* @__quantum__rt__array_get_element_ptr_1d(%Array*, i64) - -declare void @__quantum__rt__array_update_alias_count(%Array*, i64) - -declare %Result* @__quantum__qis__measure__body(%Array*, %Array*) - -declare void @__quantum__rt__array_update_reference_count(%Array*, i64) - -define %Result* @Microsoft__Quantum__Intrinsic__Measure__body(%Array* %bases, %Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %bases, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %0 = call %Result* @__quantum__qis__measure__body(%Array* %bases, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %bases, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret %Result* %0 -} - -define void @Microsoft__Quantum__Intrinsic__H__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__h__body(%Qubit* %qb) - ret void -} - -declare void @__quantum__qis__h__body(%Qubit*) - -define void @Microsoft__Quantum__Intrinsic__H__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__h__body(%Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__H__ctl(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__h__ctl(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -declare void @__quantum__qis__h__ctl(%Array*, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__H__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__h__ctl(%Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -define i64 @Microsoft__Quantum__Testing__QIR__QuantumRandomNumberGenerator__body() #0 { -entry: - %randomNumber = alloca i64 - store i64 0, i64* %randomNumber - br label %header__1 - -header__1: ; preds = %exiting__1, %entry - %i = phi i64 [ 1, %entry ], [ %8, %exiting__1 ] - %0 = icmp sle i64 %i, 64 - br i1 %0, label %body__1, label %exit__1 - -body__1: ; preds = %header__1 - %q = call %Qubit* @__quantum__rt__qubit_allocate() - call void @__quantum__qis__h__body(%Qubit* %q) - %1 = load i64, i64* %randomNumber - %2 = shl i64 %1, 1 - store i64 %2, i64* %randomNumber - %3 = call %Result* @Microsoft__Quantum__Intrinsic__M__body(%Qubit* %q) - %4 = load %Result*, %Result** @ResultOne - %5 = call i1 @__quantum__rt__result_equal(%Result* %3, %Result* %4) - br i1 %5, label %then0__1, label %continue__1 - -then0__1: ; preds = %body__1 - %6 = load i64, i64* %randomNumber - %7 = add i64 %6, 1 - store i64 %7, i64* %randomNumber - br label %continue__1 - -continue__1: ; preds = %then0__1, %body__1 - call void @__quantum__rt__qubit_release(%Qubit* %q) - call void @__quantum__rt__result_update_reference_count(%Result* %3, i64 -1) - br label %exiting__1 - -exiting__1: ; preds = %continue__1 - %8 = add i64 %i, 1 - br label %header__1 - -exit__1: ; preds = %header__1 - %9 = load i64, i64* %randomNumber - ret i64 %9 -} - -declare %Qubit* @__quantum__rt__qubit_allocate() - -declare %Array* @__quantum__rt__qubit_allocate_array(i64) - -declare i1 @__quantum__rt__result_equal(%Result*, %Result*) - -declare void @__quantum__rt__qubit_release(%Qubit*) - -declare void @__quantum__rt__result_update_reference_count(%Result*, i64) - -attributes #0 = { "EntryPoint" } diff --git a/src/QirRuntime/test/QIR-dynamic/qsharp/qir-test-random.csproj b/src/QirRuntime/test/QIR-dynamic/qsharp/qir-test-random.csproj new file mode 100644 index 00000000000..5166db5e375 --- /dev/null +++ b/src/QirRuntime/test/QIR-dynamic/qsharp/qir-test-random.csproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp3.1 + True + false + + + + + + + diff --git a/src/QirRuntime/test/QIR-dynamic/qir-test-random.qs b/src/QirRuntime/test/QIR-dynamic/qsharp/qir-test-random.qs similarity index 96% rename from src/QirRuntime/test/QIR-dynamic/qir-test-random.qs rename to src/QirRuntime/test/QIR-dynamic/qsharp/qir-test-random.qs index 7e1647bccb9..6a0b2a9787a 100644 --- a/src/QirRuntime/test/QIR-dynamic/qir-test-random.qs +++ b/src/QirRuntime/test/QIR-dynamic/qsharp/qir-test-random.qs @@ -1,25 +1,25 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -namespace Microsoft.Quantum.Testing.QIR -{ - open Microsoft.Quantum.Intrinsic; - - @EntryPoint() - operation QuantumRandomNumberGenerator() : Int { - mutable randomNumber = 0; - - for (i in 1 .. 64) - { - using(q = Qubit()) - { - H(q); - set randomNumber = randomNumber <<< 1; - if (M(q) == One) { - set randomNumber += 1; - } - } - } - return randomNumber; - } +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Testing.QIR +{ + open Microsoft.Quantum.Intrinsic; + + @EntryPoint() + operation QuantumRandomNumberGenerator() : Int { + mutable randomNumber = 0; + + for (i in 1 .. 64) + { + using(q = Qubit()) + { + H(q); + set randomNumber = randomNumber <<< 1; + if (M(q) == One) { + set randomNumber += 1; + } + } + } + return randomNumber; + } } \ No newline at end of file diff --git a/src/QirRuntime/test/QIR-static/qir-test-noqsharp.ll b/src/QirRuntime/test/QIR-static/qir-test-noqsharp.ll index 72ef01af60c..cce6f8f54c5 100644 --- a/src/QirRuntime/test/QIR-static/qir-test-noqsharp.ll +++ b/src/QirRuntime/test/QIR-static/qir-test-noqsharp.ll @@ -8,7 +8,7 @@ declare i64 @__quantum__rt__array_get_size(%Array*, i32) declare i8* @__quantum__rt__array_get_element_ptr(%Array*, ...) declare i32 @__quantum__rt__array_get_dim(%Array*) declare %Array* @__quantum__rt__array_project(%Array*, i32, i64) -declare void @__quantum__rt__array_update_reference_count(%Array*, i64) +declare void @__quantum__rt__array_update_reference_count(%Array*, i32) declare void @DebugLog(i64) ; manually authored test for multi-dimensional arrays (Q# doesn't support multi-dimentional arrays yet) @@ -25,8 +25,8 @@ define i64 @TestMultidimArrays(i8 %val, i64 %dim0, i64 %dim1, i64 %dim2) %project_val = load i8, i8* %project_elem_ptr %val64 = sext i8 %project_val to i64 - call void @__quantum__rt__array_update_reference_count(%Array* %.ar, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %.project, i64 -1) + call void @__quantum__rt__array_update_reference_count(%Array* %.ar, i32 -1) + call void @__quantum__rt__array_update_reference_count(%Array* %.project, i32 -1) %t1 = add i64 %project_dim0, %project_dim1 %t2 = sext i32 %project_dims to i64 diff --git a/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj b/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj index 071e4daa6d5..b061ce01e44 100644 --- a/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj +++ b/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/QirRuntime/test/QIR-tracer/CMakeLists.txt b/src/QirRuntime/test/QIR-tracer/CMakeLists.txt index fb6ab5bd850..dae4001b1d5 100644 --- a/src/QirRuntime/test/QIR-tracer/CMakeLists.txt +++ b/src/QirRuntime/test/QIR-tracer/CMakeLists.txt @@ -1,12 +1,6 @@ -if (WIN32) - set(TEST_FILES - tracer-qir-win - ) -else() - set(TEST_FILES - tracer-qir-lnx - ) -endif() +set(TEST_FILES + tracer-qir +) foreach(file ${TEST_FILES}) compile_from_qir(${file} "") # don't create a target per file diff --git a/src/QirRuntime/test/QIR-tracer/tracer-conditionals.qs b/src/QirRuntime/test/QIR-tracer/qsharp/tracer-conditionals.qs similarity index 97% rename from src/QirRuntime/test/QIR-tracer/tracer-conditionals.qs rename to src/QirRuntime/test/QIR-tracer/qsharp/tracer-conditionals.qs index e9c0c512421..718808a2a3b 100644 --- a/src/QirRuntime/test/QIR-tracer/tracer-conditionals.qs +++ b/src/QirRuntime/test/QIR-tracer/qsharp/tracer-conditionals.qs @@ -1,25 +1,25 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -namespace Microsoft.Quantum.Testing.Tracer { - open Microsoft.Quantum.Intrinsic; - - // Private helper operations. - operation Delay(op : (Qubit => Unit), arg : Qubit, aux : Unit) : Unit { - op(arg); - } - - operation TestMeasurements() : Unit { - use qs = Qubit[6]; - T(qs[0]); // layer 0 - let r0 = M(qs[0]); // layer 1 - T(qs[1]); // layer 0 - CNOT(qs[1], qs[2]); // layer 1 - let qs12 = [qs[1], qs[2]]; - let r12 = Measure([PauliY, PauliX], qs12); // layer 2 - - ApplyIfElseIntrinsic(r0, Delay(X, qs[3], _), Delay(Y, qs[3], _)); // layers 2, 3 - ApplyIfElseIntrinsic(r12, Delay(Z, qs[4], _), Delay(S, qs[4], _)); // layer 3, 4 - Rx(4.2, qs[5]); // layer 0 - } +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Testing.Tracer { + open Microsoft.Quantum.Intrinsic; + + // Private helper operations. + operation Delay(op : (Qubit => Unit), arg : Qubit, aux : Unit) : Unit { + op(arg); + } + + operation TestMeasurements() : Unit { + use qs = Qubit[6]; + T(qs[0]); // layer 0 + let r0 = M(qs[0]); // layer 1 + T(qs[1]); // layer 0 + CNOT(qs[1], qs[2]); // layer 1 + let qs12 = [qs[1], qs[2]]; + let r12 = Measure([PauliY, PauliX], qs12); // layer 2 + + ApplyIfElseIntrinsic(r0, Delay(X, qs[3], _), Delay(Y, qs[3], _)); // layers 2, 3 + ApplyIfElseIntrinsic(r12, Delay(Z, qs[4], _), Delay(S, qs[4], _)); // layer 3, 4 + Rx(4.2, qs[5]); // layer 0 + } } \ No newline at end of file diff --git a/src/QirRuntime/test/QIR-tracer/tracer-core.qs b/src/QirRuntime/test/QIR-tracer/qsharp/tracer-core.qs similarity index 100% rename from src/QirRuntime/test/QIR-tracer/tracer-core.qs rename to src/QirRuntime/test/QIR-tracer/qsharp/tracer-core.qs diff --git a/src/QirRuntime/test/QIR-tracer/tracer-intrinsics.qs b/src/QirRuntime/test/QIR-tracer/qsharp/tracer-intrinsics.qs similarity index 100% rename from src/QirRuntime/test/QIR-tracer/tracer-intrinsics.qs rename to src/QirRuntime/test/QIR-tracer/qsharp/tracer-intrinsics.qs diff --git a/src/QirRuntime/test/QIR-tracer/qsharp/tracer-qir.csproj b/src/QirRuntime/test/QIR-tracer/qsharp/tracer-qir.csproj new file mode 100644 index 00000000000..0167e216edf --- /dev/null +++ b/src/QirRuntime/test/QIR-tracer/qsharp/tracer-qir.csproj @@ -0,0 +1,10 @@ + + + + Exe + netcoreapp3.1 + True + false + + + diff --git a/src/QirRuntime/test/QIR-tracer/tracer-target.qs b/src/QirRuntime/test/QIR-tracer/qsharp/tracer-target.qs similarity index 100% rename from src/QirRuntime/test/QIR-tracer/tracer-target.qs rename to src/QirRuntime/test/QIR-tracer/qsharp/tracer-target.qs diff --git a/src/QirRuntime/test/QIR-tracer/tracer-qir-lnx.ll b/src/QirRuntime/test/QIR-tracer/tracer-qir-lnx.ll deleted file mode 100644 index ab33750832b..00000000000 --- a/src/QirRuntime/test/QIR-tracer/tracer-qir-lnx.ll +++ /dev/null @@ -1,2019 +0,0 @@ - -%Result = type opaque -%Range = type { i64, i64, i64 } -%Tuple = type opaque -%Array = type opaque -%Callable = type opaque -%Qubit = type opaque -%String = type opaque - -@ResultZero = external global %Result* -@ResultOne = external global %Result* -@PauliI = constant i2 0 -@PauliX = constant i2 1 -@PauliY = constant i2 -1 -@PauliZ = constant i2 -2 -@EmptyRange = internal constant %Range { i64 0, i64 1, i64 -1 } -@Microsoft__Quantum__Testing__Tracer__Delay = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Testing__Tracer__Delay__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null] -@Microsoft__Quantum__Intrinsic__X = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__X__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__X__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__X__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__X__ctladj__wrapper] -@PartialApplication__1 = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Lifted__PartialApplication__1__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null] -@MemoryManagement__1 = constant [2 x void (%Tuple*, i64)*] [void (%Tuple*, i64)* @MemoryManagement__1__RefCount, void (%Tuple*, i64)* @MemoryManagement__1__AliasCount] -@Microsoft__Quantum__Intrinsic__Y = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Y__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Y__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Y__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Y__ctladj__wrapper] -@PartialApplication__2 = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Lifted__PartialApplication__2__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null] -@Microsoft__Quantum__Intrinsic__Z = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Z__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Z__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Z__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Z__ctladj__wrapper] -@PartialApplication__3 = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Lifted__PartialApplication__3__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null] -@Microsoft__Quantum__Intrinsic__S = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__S__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__S__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__S__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__S__ctladj__wrapper] -@PartialApplication__4 = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Lifted__PartialApplication__4__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null] -@MemoryManagement__2 = constant [2 x void (%Tuple*, i64)*] [void (%Tuple*, i64)* @MemoryManagement__2__RefCount, void (%Tuple*, i64)* @MemoryManagement__2__AliasCount] - -define void @Microsoft__Quantum__Intrinsic__ApplyConditionallyIntrinsic__body(%Array* %measurementResults, %Array* %resultsValues, %Callable* %onEqualOp, %Callable* %onNonEqualOp) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %measurementResults, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %resultsValues, i64 1) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onEqualOp, i64 1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onEqualOp, i64 1) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onNonEqualOp, i64 1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onNonEqualOp, i64 1) - call void @__quantum__qis__apply_conditionally(%Array* %measurementResults, %Array* %resultsValues, %Callable* %onEqualOp, %Callable* %onNonEqualOp) - call void @__quantum__rt__array_update_alias_count(%Array* %measurementResults, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %resultsValues, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onEqualOp, i64 -1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onEqualOp, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onNonEqualOp, i64 -1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onNonEqualOp, i64 -1) - ret void -} - -declare void @__quantum__rt__array_update_alias_count(%Array*, i64) - -declare void @__quantum__rt__callable_memory_management(i32, %Callable*, i64) - -declare void @__quantum__rt__callable_update_alias_count(%Callable*, i64) - -declare void @__quantum__qis__apply_conditionally(%Array*, %Array*, %Callable*, %Callable*) - -define void @Microsoft__Quantum__Intrinsic__ApplyIfElseIntrinsic__body(%Result* %measurementResult, %Callable* %onResultZeroOp, %Callable* %onResultOneOp) { -entry: - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onResultZeroOp, i64 1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onResultZeroOp, i64 1) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onResultOneOp, i64 1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onResultOneOp, i64 1) - %0 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %1 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %0, i64 0) - %2 = bitcast i8* %1 to %Result** - store %Result* %measurementResult, %Result** %2 - %3 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %4 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %3, i64 0) - %5 = bitcast i8* %4 to %Result** - %6 = load %Result*, %Result** @ResultZero - store %Result* %6, %Result** %5 - call void @__quantum__qis__apply_conditionally(%Array* %0, %Array* %3, %Callable* %onResultZeroOp, %Callable* %onResultOneOp) - call void @__quantum__rt__result_update_reference_count(%Result* %measurementResult, i64 1) - call void @__quantum__rt__result_update_reference_count(%Result* %6, i64 1) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onResultZeroOp, i64 -1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onResultZeroOp, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onResultOneOp, i64 -1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onResultOneOp, i64 -1) - br label %header__1 - -header__1: ; preds = %exiting__1, %entry - %7 = phi i64 [ 0, %entry ], [ %12, %exiting__1 ] - %8 = icmp sle i64 %7, 0 - br i1 %8, label %body__1, label %exit__1 - -body__1: ; preds = %header__1 - %9 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %0, i64 %7) - %10 = bitcast i8* %9 to %Result** - %11 = load %Result*, %Result** %10 - call void @__quantum__rt__result_update_reference_count(%Result* %11, i64 -1) - br label %exiting__1 - -exiting__1: ; preds = %body__1 - %12 = add i64 %7, 1 - br label %header__1 - -exit__1: ; preds = %header__1 - call void @__quantum__rt__array_update_reference_count(%Array* %0, i64 -1) - br label %header__2 - -header__2: ; preds = %exiting__2, %exit__1 - %13 = phi i64 [ 0, %exit__1 ], [ %18, %exiting__2 ] - %14 = icmp sle i64 %13, 0 - br i1 %14, label %body__2, label %exit__2 - -body__2: ; preds = %header__2 - %15 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %3, i64 %13) - %16 = bitcast i8* %15 to %Result** - %17 = load %Result*, %Result** %16 - call void @__quantum__rt__result_update_reference_count(%Result* %17, i64 -1) - br label %exiting__2 - -exiting__2: ; preds = %body__2 - %18 = add i64 %13, 1 - br label %header__2 - -exit__2: ; preds = %header__2 - call void @__quantum__rt__array_update_reference_count(%Array* %3, i64 -1) - ret void -} - -declare %Array* @__quantum__rt__array_create_1d(i32, i64) - -declare i8* @__quantum__rt__array_get_element_ptr_1d(%Array*, i64) - -declare void @__quantum__rt__result_update_reference_count(%Result*, i64) - -declare void @__quantum__rt__array_update_reference_count(%Array*, i64) - -define void @Microsoft__Quantum__Intrinsic__CNOT__body(%Qubit* %control, %Qubit* %target) { -entry: - %ctls = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %0 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls, i64 0) - %1 = bitcast i8* %0 to %Qubit** - store %Qubit* %control, %Qubit** %1 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - br i1 true, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 1, i64 1, %Array* %ctls, %Qubit* %target) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 2, i64 1, %Array* %ctls, %Qubit* %target) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls, i64 -1) - ret void -} - -declare void @__quantum__qis__single_qubit_op_ctl(i64, i64, %Array*, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__CNOT__adj(%Qubit* %control, %Qubit* %target) { -entry: - call void @Microsoft__Quantum__Intrinsic__CNOT__body(%Qubit* %control, %Qubit* %target) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__CNOT__ctl(%Array* %ctls, { %Qubit*, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %1 = getelementptr inbounds { %Qubit*, %Qubit* }, { %Qubit*, %Qubit* }* %0, i32 0, i32 0 - %control = load %Qubit*, %Qubit** %1 - %2 = getelementptr inbounds { %Qubit*, %Qubit* }, { %Qubit*, %Qubit* }* %0, i32 0, i32 1 - %target = load %Qubit*, %Qubit** %2 - %3 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %4 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %3, i64 0) - %5 = bitcast i8* %4 to %Qubit** - store %Qubit* %control, %Qubit** %5 - %ctls__1 = call %Array* @__quantum__rt__array_concatenate(%Array* %ctls, %Array* %3) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__1, i64 1) - %6 = call i64 @__quantum__rt__array_get_size_1d(%Array* %ctls__1) - %7 = icmp eq i64 %6, 1 - br i1 %7, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 1, i64 1, %Array* %ctls__1, %Qubit* %target) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 2, i64 1, %Array* %ctls__1, %Qubit* %target) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__1, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %3, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__1, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -declare %Array* @__quantum__rt__array_concatenate(%Array*, %Array*) - -declare i64 @__quantum__rt__array_get_size_1d(%Array*) - -define void @Microsoft__Quantum__Intrinsic__CNOT__ctladj(%Array* %__controlQubits__, { %Qubit*, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - %1 = getelementptr inbounds { %Qubit*, %Qubit* }, { %Qubit*, %Qubit* }* %0, i32 0, i32 0 - %control = load %Qubit*, %Qubit** %1 - %2 = getelementptr inbounds { %Qubit*, %Qubit* }, { %Qubit*, %Qubit* }* %0, i32 0, i32 1 - %target = load %Qubit*, %Qubit** %2 - %3 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 2)) - %4 = bitcast %Tuple* %3 to { %Qubit*, %Qubit* }* - %5 = getelementptr inbounds { %Qubit*, %Qubit* }, { %Qubit*, %Qubit* }* %4, i32 0, i32 0 - %6 = getelementptr inbounds { %Qubit*, %Qubit* }, { %Qubit*, %Qubit* }* %4, i32 0, i32 1 - store %Qubit* %control, %Qubit** %5 - store %Qubit* %target, %Qubit** %6 - call void @Microsoft__Quantum__Intrinsic__CNOT__ctl(%Array* %__controlQubits__, { %Qubit*, %Qubit* }* %4) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %3, i64 -1) - ret void -} - -declare %Tuple* @__quantum__rt__tuple_create(i64) - -declare void @__quantum__rt__tuple_update_reference_count(%Tuple*, i64) - -define void @Microsoft__Quantum__Intrinsic__H__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 9, i64 1, %Qubit* %qb) - ret void -} - -declare void @__quantum__qis__single_qubit_op(i64, i64, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__H__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 9, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__H__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 10, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__H__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 10, i64 1, %Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -define %Result* @Microsoft__Quantum__Intrinsic__M__body(%Qubit* %qb) { -entry: - %0 = call %Result* @__quantum__qis__single_qubit_measure(i64 100, i64 1, %Qubit* %qb) - ret %Result* %0 -} - -declare %Result* @__quantum__qis__single_qubit_measure(i64, i64, %Qubit*) - -define %Result* @Microsoft__Quantum__Intrinsic__Measure__body(%Array* %paulis, %Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %0 = load %Result*, %Result** @ResultOne - %res = alloca %Result* - store %Result* %0, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %0, i64 1) - %haveY = alloca i1 - store i1 false, i1* %haveY - %1 = call i64 @__quantum__rt__array_get_size_1d(%Array* %paulis) - %2 = sub i64 %1, 1 - br label %header__1 - -header__1: ; preds = %exiting__1, %entry - %i = phi i64 [ 0, %entry ], [ %15, %exiting__1 ] - %3 = icmp sle i64 %i, %2 - br i1 %3, label %body__1, label %exit__1 - -body__1: ; preds = %header__1 - %4 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 %i) - %5 = bitcast i8* %4 to i2* - %6 = load i2, i2* %5 - %7 = load i2, i2* @PauliY - %8 = icmp eq i2 %6, %7 - %9 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 %i) - %10 = bitcast i8* %9 to i2* - %11 = load i2, i2* %10 - %12 = load i2, i2* @PauliI - %13 = icmp eq i2 %11, %12 - %14 = or i1 %8, %13 - br i1 %14, label %then0__1, label %continue__1 - -then0__1: ; preds = %body__1 - store i1 true, i1* %haveY - br label %continue__1 - -continue__1: ; preds = %then0__1, %body__1 - br label %exiting__1 - -exiting__1: ; preds = %continue__1 - %15 = add i64 %i, 1 - br label %header__1 - -exit__1: ; preds = %header__1 - %16 = load i1, i1* %haveY - br i1 %16, label %then0__2, label %test1__1 - -then0__2: ; preds = %exit__1 - %17 = call %Result* @__quantum__qis__joint_measure(i64 106, i64 1, %Array* %qubits) - call void @__quantum__rt__result_update_reference_count(%Result* %17, i64 1) - store %Result* %17, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %17, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %0, i64 -1) - br label %continue__2 - -test1__1: ; preds = %exit__1 - %18 = icmp sgt i64 %1, 2 - br i1 %18, label %then1__1, label %test2__1 - -then1__1: ; preds = %test1__1 - %19 = call %Result* @__quantum__qis__joint_measure(i64 107, i64 1, %Array* %qubits) - call void @__quantum__rt__result_update_reference_count(%Result* %19, i64 1) - %20 = load %Result*, %Result** %res - store %Result* %19, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %19, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %20, i64 -1) - br label %continue__2 - -test2__1: ; preds = %test1__1 - %21 = icmp eq i64 %1, 1 - br i1 %21, label %then2__1, label %test3__1 - -then2__1: ; preds = %test2__1 - %22 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %23 = bitcast i8* %22 to i2* - %24 = load i2, i2* %23 - %25 = load i2, i2* @PauliX - %26 = icmp eq i2 %24, %25 - br i1 %26, label %then0__3, label %else__1 - -then0__3: ; preds = %then2__1 - %27 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qubits, i64 0) - %28 = bitcast i8* %27 to %Qubit** - %qb = load %Qubit*, %Qubit** %28 - %29 = call %Result* @__quantum__qis__single_qubit_measure(i64 101, i64 1, %Qubit* %qb) - call void @__quantum__rt__result_update_reference_count(%Result* %29, i64 1) - %30 = load %Result*, %Result** %res - store %Result* %29, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %29, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %30, i64 -1) - br label %continue__3 - -else__1: ; preds = %then2__1 - %31 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qubits, i64 0) - %32 = bitcast i8* %31 to %Qubit** - %qb__1 = load %Qubit*, %Qubit** %32 - %33 = call %Result* @__quantum__qis__single_qubit_measure(i64 100, i64 1, %Qubit* %qb__1) - call void @__quantum__rt__result_update_reference_count(%Result* %33, i64 1) - %34 = load %Result*, %Result** %res - store %Result* %33, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %33, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %34, i64 -1) - br label %continue__3 - -continue__3: ; preds = %else__1, %then0__3 - br label %continue__2 - -test3__1: ; preds = %test2__1 - %35 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %36 = bitcast i8* %35 to i2* - %37 = load i2, i2* %36 - %38 = load i2, i2* @PauliX - %39 = icmp eq i2 %37, %38 - %40 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %41 = bitcast i8* %40 to i2* - %42 = load i2, i2* %41 - %43 = load i2, i2* @PauliX - %44 = icmp eq i2 %42, %43 - %45 = and i1 %39, %44 - br i1 %45, label %then3__1, label %test4__1 - -then3__1: ; preds = %test3__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %46 = call %Result* @__quantum__qis__joint_measure(i64 105, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %46, i64 1) - %47 = load %Result*, %Result** %res - store %Result* %46, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %46, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %47, i64 -1) - br label %continue__2 - -test4__1: ; preds = %test3__1 - %48 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %49 = bitcast i8* %48 to i2* - %50 = load i2, i2* %49 - %51 = load i2, i2* @PauliX - %52 = icmp eq i2 %50, %51 - %53 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %54 = bitcast i8* %53 to i2* - %55 = load i2, i2* %54 - %56 = load i2, i2* @PauliZ - %57 = icmp eq i2 %55, %56 - %58 = and i1 %52, %57 - br i1 %58, label %then4__1, label %test5__1 - -then4__1: ; preds = %test4__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %59 = call %Result* @__quantum__qis__joint_measure(i64 103, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %59, i64 1) - %60 = load %Result*, %Result** %res - store %Result* %59, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %59, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %60, i64 -1) - br label %continue__2 - -test5__1: ; preds = %test4__1 - %61 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %62 = bitcast i8* %61 to i2* - %63 = load i2, i2* %62 - %64 = load i2, i2* @PauliZ - %65 = icmp eq i2 %63, %64 - %66 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %67 = bitcast i8* %66 to i2* - %68 = load i2, i2* %67 - %69 = load i2, i2* @PauliX - %70 = icmp eq i2 %68, %69 - %71 = and i1 %65, %70 - br i1 %71, label %then5__1, label %test6__1 - -then5__1: ; preds = %test5__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %72 = call %Result* @__quantum__qis__joint_measure(i64 104, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %72, i64 1) - %73 = load %Result*, %Result** %res - store %Result* %72, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %72, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %73, i64 -1) - br label %continue__2 - -test6__1: ; preds = %test5__1 - %74 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %75 = bitcast i8* %74 to i2* - %76 = load i2, i2* %75 - %77 = load i2, i2* @PauliZ - %78 = icmp eq i2 %76, %77 - %79 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %80 = bitcast i8* %79 to i2* - %81 = load i2, i2* %80 - %82 = load i2, i2* @PauliZ - %83 = icmp eq i2 %81, %82 - %84 = and i1 %78, %83 - br i1 %84, label %then6__1, label %continue__2 - -then6__1: ; preds = %test6__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %85 = call %Result* @__quantum__qis__joint_measure(i64 102, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %85, i64 1) - %86 = load %Result*, %Result** %res - store %Result* %85, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %85, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %86, i64 -1) - br label %continue__2 - -continue__2: ; preds = %then6__1, %test6__1, %then5__1, %then4__1, %then3__1, %continue__3, %then1__1, %then0__2 - %87 = load %Result*, %Result** %res - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret %Result* %87 -} - -declare %Result* @__quantum__qis__joint_measure(i64, i64, %Array*) - -define void @Microsoft__Quantum__Intrinsic__Rx__body(double %theta, %Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 19, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Rx__adj(double %theta, %Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 19, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Rx__ctl(%Array* %ctls, { double, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %1 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 0 - %theta = load double, double* %1 - %2 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 1 - %qb = load %Qubit*, %Qubit** %2 - call void @__quantum__qis__single_qubit_op_ctl(i64 20, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Rx__ctladj(%Array* %ctls, { double, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %1 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 0 - %theta = load double, double* %1 - %2 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 1 - %qb = load %Qubit*, %Qubit** %2 - call void @__quantum__qis__single_qubit_op_ctl(i64 20, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Ry__body(double %theta, %Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 21, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Ry__adj(double %theta, %Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 21, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Ry__ctl(%Array* %ctls, { double, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %1 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 0 - %theta = load double, double* %1 - %2 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 1 - %qb = load %Qubit*, %Qubit** %2 - call void @__quantum__qis__single_qubit_op_ctl(i64 22, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Ry__ctladj(%Array* %ctls, { double, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %1 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 0 - %theta = load double, double* %1 - %2 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 1 - %qb = load %Qubit*, %Qubit** %2 - call void @__quantum__qis__single_qubit_op_ctl(i64 22, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Rz__body(double %theta, %Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 23, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Rz__adj(double %theta, %Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 23, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Rz__ctl(%Array* %ctls, { double, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %1 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 0 - %theta = load double, double* %1 - %2 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 1 - %qb = load %Qubit*, %Qubit** %2 - call void @__quantum__qis__single_qubit_op_ctl(i64 24, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Rz__ctladj(%Array* %ctls, { double, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %1 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 0 - %theta = load double, double* %1 - %2 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 1 - %qb = load %Qubit*, %Qubit** %2 - call void @__quantum__qis__single_qubit_op_ctl(i64 24, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 15, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 15, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 16, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__ctladj(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 16, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__T__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__T__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__T__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 12, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__T__ctladj(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 12, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 0, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 0, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %0 = call i64 @__quantum__rt__array_get_size_1d(%Array* %ctls) - %1 = icmp eq i64 %0, 1 - br i1 %1, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 1, i64 1, %Array* %ctls, %Qubit* %qb) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 2, i64 1, %Array* %ctls, %Qubit* %qb) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - %0 = call i64 @__quantum__rt__array_get_size_1d(%Array* %__controlQubits__) - %1 = icmp eq i64 %0, 1 - br i1 %1, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 1, i64 1, %Array* %__controlQubits__, %Qubit* %qb) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 2, i64 1, %Array* %__controlQubits__, %Qubit* %qb) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 3, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 3, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %0 = call i64 @__quantum__rt__array_get_size_1d(%Array* %ctls) - %1 = icmp eq i64 %0, 1 - br i1 %1, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 4, i64 1, %Array* %ctls, %Qubit* %qb) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 5, i64 1, %Array* %ctls, %Qubit* %qb) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - %0 = call i64 @__quantum__rt__array_get_size_1d(%Array* %__controlQubits__) - %1 = icmp eq i64 %0, 1 - br i1 %1, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 4, i64 1, %Array* %__controlQubits__, %Qubit* %qb) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 5, i64 1, %Array* %__controlQubits__, %Qubit* %qb) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 6, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 6, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %0 = call i64 @__quantum__rt__array_get_size_1d(%Array* %ctls) - %1 = icmp eq i64 %0, 1 - br i1 %1, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 7, i64 1, %Array* %ctls, %Qubit* %qb) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 8, i64 1, %Array* %ctls, %Qubit* %qb) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - %0 = call i64 @__quantum__rt__array_get_size_1d(%Array* %__controlQubits__) - %1 = icmp eq i64 %0, 1 - br i1 %1, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 7, i64 1, %Array* %__controlQubits__, %Qubit* %qb) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 8, i64 1, %Array* %__controlQubits__, %Qubit* %qb) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -define %Tuple* @Microsoft__Quantum__Core__Attribute__body() { -entry: - ret %Tuple* null -} - -define %Tuple* @Microsoft__Quantum__Core__EntryPoint__body() { -entry: - ret %Tuple* null -} - -define %Tuple* @Microsoft__Quantum__Core__Inline__body() { -entry: - ret %Tuple* null -} - -define %Result* @Microsoft__Quantum__Instructions__Mx__body(%Qubit* %qb) { -entry: - %0 = call %Result* @__quantum__qis__single_qubit_measure(i64 101, i64 1, %Qubit* %qb) - ret %Result* %0 -} - -define %Result* @Microsoft__Quantum__Instructions__Mxx__body(%Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %0 = call %Result* @__quantum__qis__joint_measure(i64 105, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret %Result* %0 -} - -define %Result* @Microsoft__Quantum__Instructions__Mxz__body(%Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %0 = call %Result* @__quantum__qis__joint_measure(i64 103, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret %Result* %0 -} - -define %Result* @Microsoft__Quantum__Instructions__Mz__body(%Qubit* %qb) { -entry: - %0 = call %Result* @__quantum__qis__single_qubit_measure(i64 100, i64 1, %Qubit* %qb) - ret %Result* %0 -} - -define %Result* @Microsoft__Quantum__Instructions__Mzx__body(%Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %0 = call %Result* @__quantum__qis__joint_measure(i64 104, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret %Result* %0 -} - -define %Result* @Microsoft__Quantum__Instructions__Mzz__body(%Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %0 = call %Result* @__quantum__qis__joint_measure(i64 102, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret %Result* %0 -} - -define void @Microsoft__Quantum__Instructions__Sx__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 17, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Sx__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 17, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Sx__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 18, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Instructions__Sx__ctladj(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 18, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Instructions__Sz__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 15, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Sz__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 15, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Sz__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 16, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Instructions__Sz__ctladj(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 16, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tx__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 13, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tx__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 13, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tx__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 14, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tx__ctladj(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 14, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tz__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tz__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tz__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 12, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tz__ctladj(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 12, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Testing__Tracer__Delay__body(%Callable* %op, %Qubit* %arg, %Tuple* %aux) { -entry: - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %op, i64 1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %op, i64 1) - %0 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64)) - %1 = bitcast %Tuple* %0 to { %Qubit* }* - %2 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %1, i32 0, i32 0 - store %Qubit* %arg, %Qubit** %2 - call void @__quantum__rt__callable_invoke(%Callable* %op, %Tuple* %0, %Tuple* null) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %op, i64 -1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %op, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %0, i64 -1) - ret void -} - -declare void @__quantum__rt__callable_invoke(%Callable*, %Tuple*, %Tuple*) - -define void @Microsoft__Quantum__Testing__Tracer__TestCoreIntrinsics__body() { -entry: - %qs = call %Array* @__quantum__rt__qubit_allocate_array(i64 3) - call void @__quantum__rt__array_update_alias_count(%Array* %qs, i64 1) - %0 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %1 = bitcast i8* %0 to %Qubit** - %qb = load %Qubit*, %Qubit** %1 - call void @__quantum__qis__single_qubit_op(i64 0, i64 1, %Qubit* %qb) - %2 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %3 = bitcast i8* %2 to %Qubit** - %qb__1 = load %Qubit*, %Qubit** %3 - call void @__quantum__qis__single_qubit_op(i64 3, i64 1, %Qubit* %qb__1) - %4 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %5 = bitcast i8* %4 to %Qubit** - %qb__2 = load %Qubit*, %Qubit** %5 - call void @__quantum__qis__single_qubit_op(i64 6, i64 1, %Qubit* %qb__2) - %6 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %7 = bitcast i8* %6 to %Qubit** - %qb__3 = load %Qubit*, %Qubit** %7 - call void @__quantum__qis__single_qubit_op(i64 9, i64 1, %Qubit* %qb__3) - %8 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %9 = bitcast i8* %8 to %Qubit** - %10 = load %Qubit*, %Qubit** %9 - %11 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %12 = bitcast i8* %11 to %Qubit** - %13 = load %Qubit*, %Qubit** %12 - call void @Microsoft__Quantum__Intrinsic__CNOT__body(%Qubit* %10, %Qubit* %13) - %14 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %15 = bitcast i8* %14 to %Qubit** - %qb__4 = load %Qubit*, %Qubit** %15 - call void @__quantum__qis__single_qubit_op(i64 19, i64 1, %Qubit* %qb__4) - %16 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %17 = bitcast i8* %16 to %Qubit** - %qb__5 = load %Qubit*, %Qubit** %17 - call void @__quantum__qis__single_qubit_op(i64 21, i64 1, %Qubit* %qb__5) - %18 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %19 = bitcast i8* %18 to %Qubit** - %qb__6 = load %Qubit*, %Qubit** %19 - call void @__quantum__qis__single_qubit_op(i64 23, i64 1, %Qubit* %qb__6) - %20 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %21 = bitcast i8* %20 to %Qubit** - %qb__7 = load %Qubit*, %Qubit** %21 - call void @__quantum__qis__single_qubit_op(i64 15, i64 1, %Qubit* %qb__7) - %22 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %23 = bitcast i8* %22 to %Qubit** - %qb__9 = load %Qubit*, %Qubit** %23 - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb__9) - call void @__quantum__qis__inject_barrier(i64 42, i64 0) - %24 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %25 = bitcast i8* %24 to %Qubit** - %qb__11 = load %Qubit*, %Qubit** %25 - call void @__quantum__qis__single_qubit_op(i64 0, i64 1, %Qubit* %qb__11) - %26 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %27 = bitcast i8* %26 to %Qubit** - %qb__13 = load %Qubit*, %Qubit** %27 - call void @__quantum__qis__single_qubit_op(i64 3, i64 1, %Qubit* %qb__13) - %28 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %29 = bitcast i8* %28 to %Qubit** - %qb__15 = load %Qubit*, %Qubit** %29 - call void @__quantum__qis__single_qubit_op(i64 6, i64 1, %Qubit* %qb__15) - %30 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %31 = bitcast i8* %30 to %Qubit** - %qb__17 = load %Qubit*, %Qubit** %31 - call void @__quantum__qis__single_qubit_op(i64 9, i64 1, %Qubit* %qb__17) - %32 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %33 = bitcast i8* %32 to %Qubit** - %34 = load %Qubit*, %Qubit** %33 - %35 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %36 = bitcast i8* %35 to %Qubit** - %37 = load %Qubit*, %Qubit** %36 - call void @Microsoft__Quantum__Intrinsic__CNOT__adj(%Qubit* %34, %Qubit* %37) - %38 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %39 = bitcast i8* %38 to %Qubit** - %qb__19 = load %Qubit*, %Qubit** %39 - call void @__quantum__qis__single_qubit_op(i64 19, i64 1, %Qubit* %qb__19) - %40 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %41 = bitcast i8* %40 to %Qubit** - %qb__20 = load %Qubit*, %Qubit** %41 - call void @__quantum__qis__single_qubit_op(i64 21, i64 1, %Qubit* %qb__20) - %42 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %43 = bitcast i8* %42 to %Qubit** - %qb__21 = load %Qubit*, %Qubit** %43 - call void @__quantum__qis__single_qubit_op(i64 23, i64 1, %Qubit* %qb__21) - %44 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %45 = bitcast i8* %44 to %Qubit** - %qb__22 = load %Qubit*, %Qubit** %45 - call void @__quantum__qis__single_qubit_op(i64 15, i64 1, %Qubit* %qb__22) - %46 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %47 = bitcast i8* %46 to %Qubit** - %qb__24 = load %Qubit*, %Qubit** %47 - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb__24) - %c = call %Qubit* @__quantum__rt__qubit_allocate() - %ctls = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %48 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls, i64 0) - %49 = bitcast i8* %48 to %Qubit** - store %Qubit* %c, %Qubit** %49 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %50 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %51 = bitcast i8* %50 to %Qubit** - %qb__26 = load %Qubit*, %Qubit** %51 - br i1 true, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 1, i64 1, %Array* %ctls, %Qubit* %qb__26) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 2, i64 1, %Array* %ctls, %Qubit* %qb__26) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls, i64 -1) - %ctls__1 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %52 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__1, i64 0) - %53 = bitcast i8* %52 to %Qubit** - store %Qubit* %c, %Qubit** %53 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__1, i64 1) - %54 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %55 = bitcast i8* %54 to %Qubit** - %qb__27 = load %Qubit*, %Qubit** %55 - br i1 true, label %then0__2, label %else__2 - -then0__2: ; preds = %continue__1 - call void @__quantum__qis__single_qubit_op_ctl(i64 4, i64 1, %Array* %ctls__1, %Qubit* %qb__27) - br label %continue__2 - -else__2: ; preds = %continue__1 - call void @__quantum__qis__single_qubit_op_ctl(i64 5, i64 1, %Array* %ctls__1, %Qubit* %qb__27) - br label %continue__2 - -continue__2: ; preds = %else__2, %then0__2 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__1, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__1, i64 -1) - %ctls__2 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %56 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__2, i64 0) - %57 = bitcast i8* %56 to %Qubit** - store %Qubit* %c, %Qubit** %57 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__2, i64 1) - %58 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %59 = bitcast i8* %58 to %Qubit** - %qb__28 = load %Qubit*, %Qubit** %59 - br i1 true, label %then0__3, label %else__3 - -then0__3: ; preds = %continue__2 - call void @__quantum__qis__single_qubit_op_ctl(i64 7, i64 1, %Array* %ctls__2, %Qubit* %qb__28) - br label %continue__3 - -else__3: ; preds = %continue__2 - call void @__quantum__qis__single_qubit_op_ctl(i64 8, i64 1, %Array* %ctls__2, %Qubit* %qb__28) - br label %continue__3 - -continue__3: ; preds = %else__3, %then0__3 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__2, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__2, i64 -1) - %ctls__3 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %60 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__3, i64 0) - %61 = bitcast i8* %60 to %Qubit** - store %Qubit* %c, %Qubit** %61 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__3, i64 1) - %62 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %63 = bitcast i8* %62 to %Qubit** - %qb__29 = load %Qubit*, %Qubit** %63 - call void @__quantum__qis__single_qubit_op_ctl(i64 10, i64 1, %Array* %ctls__3, %Qubit* %qb__29) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__3, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__3, i64 -1) - %ctls__4 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %64 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__4, i64 0) - %65 = bitcast i8* %64 to %Qubit** - store %Qubit* %c, %Qubit** %65 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__4, i64 1) - %66 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %67 = bitcast i8* %66 to %Qubit** - %qb__30 = load %Qubit*, %Qubit** %67 - call void @__quantum__qis__single_qubit_op_ctl(i64 20, i64 1, %Array* %ctls__4, %Qubit* %qb__30) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__4, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__4, i64 -1) - %ctls__5 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %68 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__5, i64 0) - %69 = bitcast i8* %68 to %Qubit** - store %Qubit* %c, %Qubit** %69 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__5, i64 1) - %70 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %71 = bitcast i8* %70 to %Qubit** - %qb__31 = load %Qubit*, %Qubit** %71 - call void @__quantum__qis__single_qubit_op_ctl(i64 22, i64 1, %Array* %ctls__5, %Qubit* %qb__31) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__5, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__5, i64 -1) - %ctls__6 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %72 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__6, i64 0) - %73 = bitcast i8* %72 to %Qubit** - store %Qubit* %c, %Qubit** %73 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__6, i64 1) - %74 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %75 = bitcast i8* %74 to %Qubit** - %qb__32 = load %Qubit*, %Qubit** %75 - call void @__quantum__qis__single_qubit_op_ctl(i64 24, i64 1, %Array* %ctls__6, %Qubit* %qb__32) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__6, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__6, i64 -1) - %ctls__7 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %76 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__7, i64 0) - %77 = bitcast i8* %76 to %Qubit** - store %Qubit* %c, %Qubit** %77 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__7, i64 1) - %78 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %79 = bitcast i8* %78 to %Qubit** - %qb__33 = load %Qubit*, %Qubit** %79 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__7, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 16, i64 1, %Array* %ctls__7, %Qubit* %qb__33) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__7, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__7, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__7, i64 -1) - %ctls__9 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %80 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__9, i64 0) - %81 = bitcast i8* %80 to %Qubit** - store %Qubit* %c, %Qubit** %81 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__9, i64 1) - %82 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %83 = bitcast i8* %82 to %Qubit** - %qb__35 = load %Qubit*, %Qubit** %83 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__9, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 12, i64 1, %Array* %ctls__9, %Qubit* %qb__35) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__9, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__9, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__9, i64 -1) - call void @__quantum__rt__qubit_release(%Qubit* %c) - %cc = call %Array* @__quantum__rt__qubit_allocate_array(i64 2) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %84 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %85 = bitcast i8* %84 to %Qubit** - %qb__37 = load %Qubit*, %Qubit** %85 - %86 = call i64 @__quantum__rt__array_get_size_1d(%Array* %cc) - %87 = icmp eq i64 %86, 1 - br i1 %87, label %then0__4, label %else__4 - -then0__4: ; preds = %continue__3 - call void @__quantum__qis__single_qubit_op_ctl(i64 1, i64 1, %Array* %cc, %Qubit* %qb__37) - br label %continue__4 - -else__4: ; preds = %continue__3 - call void @__quantum__qis__single_qubit_op_ctl(i64 2, i64 1, %Array* %cc, %Qubit* %qb__37) - br label %continue__4 - -continue__4: ; preds = %else__4, %then0__4 - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %88 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %89 = bitcast i8* %88 to %Qubit** - %qb__38 = load %Qubit*, %Qubit** %89 - %90 = icmp eq i64 %86, 1 - br i1 %90, label %then0__5, label %else__5 - -then0__5: ; preds = %continue__4 - call void @__quantum__qis__single_qubit_op_ctl(i64 4, i64 1, %Array* %cc, %Qubit* %qb__38) - br label %continue__5 - -else__5: ; preds = %continue__4 - call void @__quantum__qis__single_qubit_op_ctl(i64 5, i64 1, %Array* %cc, %Qubit* %qb__38) - br label %continue__5 - -continue__5: ; preds = %else__5, %then0__5 - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %91 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %92 = bitcast i8* %91 to %Qubit** - %qb__39 = load %Qubit*, %Qubit** %92 - %93 = icmp eq i64 %86, 1 - br i1 %93, label %then0__6, label %else__6 - -then0__6: ; preds = %continue__5 - call void @__quantum__qis__single_qubit_op_ctl(i64 7, i64 1, %Array* %cc, %Qubit* %qb__39) - br label %continue__6 - -else__6: ; preds = %continue__5 - call void @__quantum__qis__single_qubit_op_ctl(i64 8, i64 1, %Array* %cc, %Qubit* %qb__39) - br label %continue__6 - -continue__6: ; preds = %else__6, %then0__6 - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %94 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %95 = bitcast i8* %94 to %Qubit** - %qb__40 = load %Qubit*, %Qubit** %95 - call void @__quantum__qis__single_qubit_op_ctl(i64 10, i64 1, %Array* %cc, %Qubit* %qb__40) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %96 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %97 = bitcast i8* %96 to %Qubit** - %qb__41 = load %Qubit*, %Qubit** %97 - call void @__quantum__qis__single_qubit_op_ctl(i64 20, i64 1, %Array* %cc, %Qubit* %qb__41) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %98 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %99 = bitcast i8* %98 to %Qubit** - %qb__42 = load %Qubit*, %Qubit** %99 - call void @__quantum__qis__single_qubit_op_ctl(i64 22, i64 1, %Array* %cc, %Qubit* %qb__42) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %100 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %101 = bitcast i8* %100 to %Qubit** - %qb__43 = load %Qubit*, %Qubit** %101 - call void @__quantum__qis__single_qubit_op_ctl(i64 24, i64 1, %Array* %cc, %Qubit* %qb__43) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %102 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %103 = bitcast i8* %102 to %Qubit** - %qb__44 = load %Qubit*, %Qubit** %103 - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 16, i64 1, %Array* %cc, %Qubit* %qb__44) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %104 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %105 = bitcast i8* %104 to %Qubit** - %qb__46 = load %Qubit*, %Qubit** %105 - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 12, i64 1, %Array* %cc, %Qubit* %qb__46) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__qubit_release_array(%Array* %cc) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %cc, i64 -1) - call void @__quantum__rt__qubit_release_array(%Array* %qs) - call void @__quantum__rt__array_update_alias_count(%Array* %qs, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %qs, i64 -1) - ret void -} - -declare %Qubit* @__quantum__rt__qubit_allocate() - -declare %Array* @__quantum__rt__qubit_allocate_array(i64) - -declare void @__quantum__qis__inject_barrier(i64, i64) - -declare void @__quantum__rt__qubit_release(%Qubit*) - -declare void @__quantum__rt__qubit_release_array(%Array*) - -define void @Microsoft__Quantum__Testing__Tracer__TestMeasurements__body() { -entry: - %qs = call %Array* @__quantum__rt__qubit_allocate_array(i64 6) - call void @__quantum__rt__array_update_alias_count(%Array* %qs, i64 1) - %0 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %1 = bitcast i8* %0 to %Qubit** - %qb = load %Qubit*, %Qubit** %1 - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb) - %2 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %3 = bitcast i8* %2 to %Qubit** - %qb__2 = load %Qubit*, %Qubit** %3 - %r0 = call %Result* @__quantum__qis__single_qubit_measure(i64 100, i64 1, %Qubit* %qb__2) - %4 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %5 = bitcast i8* %4 to %Qubit** - %qb__4 = load %Qubit*, %Qubit** %5 - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb__4) - %6 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %7 = bitcast i8* %6 to %Qubit** - %8 = load %Qubit*, %Qubit** %7 - %9 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %10 = bitcast i8* %9 to %Qubit** - %11 = load %Qubit*, %Qubit** %10 - call void @Microsoft__Quantum__Intrinsic__CNOT__body(%Qubit* %8, %Qubit* %11) - %qs12 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 2) - %12 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs12, i64 0) - %13 = bitcast i8* %12 to %Qubit** - %14 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs12, i64 1) - %15 = bitcast i8* %14 to %Qubit** - %16 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %17 = bitcast i8* %16 to %Qubit** - %18 = load %Qubit*, %Qubit** %17 - %19 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %20 = bitcast i8* %19 to %Qubit** - %21 = load %Qubit*, %Qubit** %20 - store %Qubit* %18, %Qubit** %13 - store %Qubit* %21, %Qubit** %15 - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 1) - %paulis = call %Array* @__quantum__rt__array_create_1d(i32 1, i64 2) - %22 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %23 = bitcast i8* %22 to i2* - %24 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %25 = bitcast i8* %24 to i2* - %26 = load i2, i2* @PauliY - %27 = load i2, i2* @PauliX - store i2 %26, i2* %23 - store i2 %27, i2* %25 - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 1) - %28 = load %Result*, %Result** @ResultOne - %res = alloca %Result* - store %Result* %28, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %28, i64 1) - %haveY = alloca i1 - store i1 false, i1* %haveY - br label %header__1 - -header__1: ; preds = %exiting__1, %entry - %i = phi i64 [ 0, %entry ], [ %41, %exiting__1 ] - %29 = icmp sle i64 %i, 1 - br i1 %29, label %body__1, label %exit__1 - -body__1: ; preds = %header__1 - %30 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 %i) - %31 = bitcast i8* %30 to i2* - %32 = load i2, i2* %31 - %33 = load i2, i2* @PauliY - %34 = icmp eq i2 %32, %33 - %35 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 %i) - %36 = bitcast i8* %35 to i2* - %37 = load i2, i2* %36 - %38 = load i2, i2* @PauliI - %39 = icmp eq i2 %37, %38 - %40 = or i1 %34, %39 - br i1 %40, label %then0__1, label %continue__1 - -then0__1: ; preds = %body__1 - store i1 true, i1* %haveY - br label %continue__1 - -continue__1: ; preds = %then0__1, %body__1 - br label %exiting__1 - -exiting__1: ; preds = %continue__1 - %41 = add i64 %i, 1 - br label %header__1 - -exit__1: ; preds = %header__1 - %42 = load i1, i1* %haveY - br i1 %42, label %then0__2, label %test1__1 - -then0__2: ; preds = %exit__1 - %43 = call %Result* @__quantum__qis__joint_measure(i64 106, i64 1, %Array* %qs12) - call void @__quantum__rt__result_update_reference_count(%Result* %43, i64 1) - store %Result* %43, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %43, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %28, i64 -1) - br label %continue__2 - -test1__1: ; preds = %exit__1 - br i1 false, label %then1__1, label %test2__1 - -then1__1: ; preds = %test1__1 - %44 = call %Result* @__quantum__qis__joint_measure(i64 107, i64 1, %Array* %qs12) - call void @__quantum__rt__result_update_reference_count(%Result* %44, i64 1) - %45 = load %Result*, %Result** %res - store %Result* %44, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %44, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %45, i64 -1) - br label %continue__2 - -test2__1: ; preds = %test1__1 - br i1 false, label %then2__1, label %test3__1 - -then2__1: ; preds = %test2__1 - %46 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %47 = bitcast i8* %46 to i2* - %48 = load i2, i2* %47 - %49 = load i2, i2* @PauliX - %50 = icmp eq i2 %48, %49 - br i1 %50, label %then0__3, label %else__1 - -then0__3: ; preds = %then2__1 - %51 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs12, i64 0) - %52 = bitcast i8* %51 to %Qubit** - %qb__6 = load %Qubit*, %Qubit** %52 - %53 = call %Result* @__quantum__qis__single_qubit_measure(i64 101, i64 1, %Qubit* %qb__6) - call void @__quantum__rt__result_update_reference_count(%Result* %53, i64 1) - %54 = load %Result*, %Result** %res - store %Result* %53, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %53, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %54, i64 -1) - br label %continue__3 - -else__1: ; preds = %then2__1 - %55 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs12, i64 0) - %56 = bitcast i8* %55 to %Qubit** - %qb__7 = load %Qubit*, %Qubit** %56 - %57 = call %Result* @__quantum__qis__single_qubit_measure(i64 100, i64 1, %Qubit* %qb__7) - call void @__quantum__rt__result_update_reference_count(%Result* %57, i64 1) - %58 = load %Result*, %Result** %res - store %Result* %57, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %57, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %58, i64 -1) - br label %continue__3 - -continue__3: ; preds = %else__1, %then0__3 - br label %continue__2 - -test3__1: ; preds = %test2__1 - %59 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %60 = bitcast i8* %59 to i2* - %61 = load i2, i2* %60 - %62 = load i2, i2* @PauliX - %63 = icmp eq i2 %61, %62 - %64 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %65 = bitcast i8* %64 to i2* - %66 = load i2, i2* %65 - %67 = load i2, i2* @PauliX - %68 = icmp eq i2 %66, %67 - %69 = and i1 %63, %68 - br i1 %69, label %then3__1, label %test4__1 - -then3__1: ; preds = %test3__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 1) - %70 = call %Result* @__quantum__qis__joint_measure(i64 105, i64 1, %Array* %qs12) - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %70, i64 1) - %71 = load %Result*, %Result** %res - store %Result* %70, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %70, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %71, i64 -1) - br label %continue__2 - -test4__1: ; preds = %test3__1 - %72 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %73 = bitcast i8* %72 to i2* - %74 = load i2, i2* %73 - %75 = load i2, i2* @PauliX - %76 = icmp eq i2 %74, %75 - %77 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %78 = bitcast i8* %77 to i2* - %79 = load i2, i2* %78 - %80 = load i2, i2* @PauliZ - %81 = icmp eq i2 %79, %80 - %82 = and i1 %76, %81 - br i1 %82, label %then4__1, label %test5__1 - -then4__1: ; preds = %test4__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 1) - %83 = call %Result* @__quantum__qis__joint_measure(i64 103, i64 1, %Array* %qs12) - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %83, i64 1) - %84 = load %Result*, %Result** %res - store %Result* %83, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %83, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %84, i64 -1) - br label %continue__2 - -test5__1: ; preds = %test4__1 - %85 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %86 = bitcast i8* %85 to i2* - %87 = load i2, i2* %86 - %88 = load i2, i2* @PauliZ - %89 = icmp eq i2 %87, %88 - %90 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %91 = bitcast i8* %90 to i2* - %92 = load i2, i2* %91 - %93 = load i2, i2* @PauliX - %94 = icmp eq i2 %92, %93 - %95 = and i1 %89, %94 - br i1 %95, label %then5__1, label %test6__1 - -then5__1: ; preds = %test5__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 1) - %96 = call %Result* @__quantum__qis__joint_measure(i64 104, i64 1, %Array* %qs12) - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %96, i64 1) - %97 = load %Result*, %Result** %res - store %Result* %96, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %96, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %97, i64 -1) - br label %continue__2 - -test6__1: ; preds = %test5__1 - %98 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %99 = bitcast i8* %98 to i2* - %100 = load i2, i2* %99 - %101 = load i2, i2* @PauliZ - %102 = icmp eq i2 %100, %101 - %103 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %104 = bitcast i8* %103 to i2* - %105 = load i2, i2* %104 - %106 = load i2, i2* @PauliZ - %107 = icmp eq i2 %105, %106 - %108 = and i1 %102, %107 - br i1 %108, label %then6__1, label %continue__2 - -then6__1: ; preds = %test6__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 1) - %109 = call %Result* @__quantum__qis__joint_measure(i64 102, i64 1, %Array* %qs12) - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %109, i64 1) - %110 = load %Result*, %Result** %res - store %Result* %109, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %109, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %110, i64 -1) - br label %continue__2 - -continue__2: ; preds = %then6__1, %test6__1, %then5__1, %then4__1, %then3__1, %continue__3, %then1__1, %then0__2 - %r12 = load %Result*, %Result** %res - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %paulis, i64 -1) - %111 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %112 = bitcast %Tuple* %111 to { %Callable*, %Callable*, %Qubit* }* - %113 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %112, i32 0, i32 0 - %114 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %112, i32 0, i32 1 - %115 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %112, i32 0, i32 2 - %116 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Testing__Tracer__Delay, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %117 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__X, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %118 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 3) - %119 = bitcast i8* %118 to %Qubit** - %120 = load %Qubit*, %Qubit** %119 - store %Callable* %116, %Callable** %113 - store %Callable* %117, %Callable** %114 - store %Qubit* %120, %Qubit** %115 - %121 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @PartialApplication__1, [2 x void (%Tuple*, i64)*]* @MemoryManagement__1, %Tuple* %111) - %122 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %123 = bitcast %Tuple* %122 to { %Callable*, %Callable*, %Qubit* }* - %124 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %123, i32 0, i32 0 - %125 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %123, i32 0, i32 1 - %126 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %123, i32 0, i32 2 - %127 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Testing__Tracer__Delay, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %128 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__Y, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %129 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 3) - %130 = bitcast i8* %129 to %Qubit** - %131 = load %Qubit*, %Qubit** %130 - store %Callable* %127, %Callable** %124 - store %Callable* %128, %Callable** %125 - store %Qubit* %131, %Qubit** %126 - %132 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @PartialApplication__2, [2 x void (%Tuple*, i64)*]* @MemoryManagement__1, %Tuple* %122) - call void @Microsoft__Quantum__Intrinsic__ApplyIfElseIntrinsic__body(%Result* %r0, %Callable* %121, %Callable* %132) - %133 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %134 = bitcast %Tuple* %133 to { %Callable*, %Callable*, %Qubit* }* - %135 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %134, i32 0, i32 0 - %136 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %134, i32 0, i32 1 - %137 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %134, i32 0, i32 2 - %138 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Testing__Tracer__Delay, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %139 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__Z, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %140 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 4) - %141 = bitcast i8* %140 to %Qubit** - %142 = load %Qubit*, %Qubit** %141 - store %Callable* %138, %Callable** %135 - store %Callable* %139, %Callable** %136 - store %Qubit* %142, %Qubit** %137 - %143 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @PartialApplication__3, [2 x void (%Tuple*, i64)*]* @MemoryManagement__1, %Tuple* %133) - %144 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %145 = bitcast %Tuple* %144 to { %Callable*, %Callable*, %Qubit* }* - %146 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %145, i32 0, i32 0 - %147 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %145, i32 0, i32 1 - %148 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %145, i32 0, i32 2 - %149 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Testing__Tracer__Delay, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %150 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__S, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %151 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 4) - %152 = bitcast i8* %151 to %Qubit** - %153 = load %Qubit*, %Qubit** %152 - store %Callable* %149, %Callable** %146 - store %Callable* %150, %Callable** %147 - store %Qubit* %153, %Qubit** %148 - %154 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @PartialApplication__4, [2 x void (%Tuple*, i64)*]* @MemoryManagement__2, %Tuple* %144) - call void @Microsoft__Quantum__Intrinsic__ApplyIfElseIntrinsic__body(%Result* %r12, %Callable* %143, %Callable* %154) - %155 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 5) - %156 = bitcast i8* %155 to %Qubit** - %qb__8 = load %Qubit*, %Qubit** %156 - call void @__quantum__qis__single_qubit_op(i64 19, i64 1, %Qubit* %qb__8) - call void @__quantum__rt__qubit_release_array(%Array* %qs) - call void @__quantum__rt__array_update_alias_count(%Array* %qs, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %qs, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %r0, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %qs12, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %r12, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %121, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %121, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %132, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %132, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %143, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %143, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %154, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %154, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Testing__Tracer__Delay__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Callable*, %Qubit*, %Tuple* }* - %1 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %0, i32 0, i32 1 - %3 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %0, i32 0, i32 2 - %4 = load %Callable*, %Callable** %1 - %5 = load %Qubit*, %Qubit** %2 - %6 = load %Tuple*, %Tuple** %3 - call void @Microsoft__Quantum__Testing__Tracer__Delay__body(%Callable* %4, %Qubit* %5, %Tuple* %6) - ret void -} - -declare %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]*, [2 x void (%Tuple*, i64)*]*, %Tuple*) - -define void @Microsoft__Quantum__Intrinsic__X__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__X__body(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__X__adj(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__X__ctl(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__X__ctladj(%Array* %3, %Qubit* %4) - ret void -} - -define void @Lifted__PartialApplication__1__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %2 = load %Callable*, %Callable** %1 - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 2 - %4 = load %Qubit*, %Qubit** %3 - %5 = bitcast %Tuple* %arg-tuple to { %Tuple* }* - %6 = getelementptr inbounds { %Tuple* }, { %Tuple* }* %5, i32 0, i32 0 - %7 = load %Tuple*, %Tuple** %6 - %8 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %9 = bitcast %Tuple* %8 to { %Callable*, %Qubit*, %Tuple* }* - %10 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 0 - %11 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 1 - %12 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 2 - store %Callable* %2, %Callable** %10 - store %Qubit* %4, %Qubit** %11 - store %Tuple* %7, %Tuple** %12 - %13 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %14 = load %Callable*, %Callable** %13 - call void @__quantum__rt__callable_invoke(%Callable* %14, %Tuple* %8, %Tuple* %result-tuple) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %8, i64 -1) - ret void -} - -define void @MemoryManagement__1__RefCount(%Tuple* %capture-tuple, i64 %count-change) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %2 = load %Callable*, %Callable** %1 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %2, i64 %count-change) - call void @__quantum__rt__callable_update_reference_count(%Callable* %2, i64 %count-change) - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %4 = load %Callable*, %Callable** %3 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %4, i64 %count-change) - call void @__quantum__rt__callable_update_reference_count(%Callable* %4, i64 %count-change) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %capture-tuple, i64 %count-change) - ret void -} - -define void @MemoryManagement__1__AliasCount(%Tuple* %capture-tuple, i64 %count-change) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %2 = load %Callable*, %Callable** %1 - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %2, i64 %count-change) - call void @__quantum__rt__callable_update_alias_count(%Callable* %2, i64 %count-change) - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %4 = load %Callable*, %Callable** %3 - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %4, i64 %count-change) - call void @__quantum__rt__callable_update_alias_count(%Callable* %4, i64 %count-change) - call void @__quantum__rt__tuple_update_alias_count(%Tuple* %capture-tuple, i64 %count-change) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__Y__body(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__Y__adj(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__Y__ctl(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__Y__ctladj(%Array* %3, %Qubit* %4) - ret void -} - -define void @Lifted__PartialApplication__2__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %2 = load %Callable*, %Callable** %1 - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 2 - %4 = load %Qubit*, %Qubit** %3 - %5 = bitcast %Tuple* %arg-tuple to { %Tuple* }* - %6 = getelementptr inbounds { %Tuple* }, { %Tuple* }* %5, i32 0, i32 0 - %7 = load %Tuple*, %Tuple** %6 - %8 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %9 = bitcast %Tuple* %8 to { %Callable*, %Qubit*, %Tuple* }* - %10 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 0 - %11 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 1 - %12 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 2 - store %Callable* %2, %Callable** %10 - store %Qubit* %4, %Qubit** %11 - store %Tuple* %7, %Tuple** %12 - %13 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %14 = load %Callable*, %Callable** %13 - call void @__quantum__rt__callable_invoke(%Callable* %14, %Tuple* %8, %Tuple* %result-tuple) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %8, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__Z__body(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__Z__adj(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__Z__ctl(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__Z__ctladj(%Array* %3, %Qubit* %4) - ret void -} - -define void @Lifted__PartialApplication__3__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %2 = load %Callable*, %Callable** %1 - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 2 - %4 = load %Qubit*, %Qubit** %3 - %5 = bitcast %Tuple* %arg-tuple to { %Tuple* }* - %6 = getelementptr inbounds { %Tuple* }, { %Tuple* }* %5, i32 0, i32 0 - %7 = load %Tuple*, %Tuple** %6 - %8 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %9 = bitcast %Tuple* %8 to { %Callable*, %Qubit*, %Tuple* }* - %10 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 0 - %11 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 1 - %12 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 2 - store %Callable* %2, %Callable** %10 - store %Qubit* %4, %Qubit** %11 - store %Tuple* %7, %Tuple** %12 - %13 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %14 = load %Callable*, %Callable** %13 - call void @__quantum__rt__callable_invoke(%Callable* %14, %Tuple* %8, %Tuple* %result-tuple) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %8, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__S__body(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__S__adj(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__S__ctl(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__S__ctladj(%Array* %3, %Qubit* %4) - ret void -} - -define void @Lifted__PartialApplication__4__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %2 = load %Callable*, %Callable** %1 - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 2 - %4 = load %Qubit*, %Qubit** %3 - %5 = bitcast %Tuple* %arg-tuple to { %Tuple* }* - %6 = getelementptr inbounds { %Tuple* }, { %Tuple* }* %5, i32 0, i32 0 - %7 = load %Tuple*, %Tuple** %6 - %8 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %9 = bitcast %Tuple* %8 to { %Callable*, %Qubit*, %Tuple* }* - %10 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 0 - %11 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 1 - %12 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 2 - store %Callable* %2, %Callable** %10 - store %Qubit* %4, %Qubit** %11 - store %Tuple* %7, %Tuple** %12 - %13 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %14 = load %Callable*, %Callable** %13 - call void @__quantum__rt__callable_invoke(%Callable* %14, %Tuple* %8, %Tuple* %result-tuple) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %8, i64 -1) - ret void -} - -define void @MemoryManagement__2__RefCount(%Tuple* %capture-tuple, i64 %count-change) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %2 = load %Callable*, %Callable** %1 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %2, i64 %count-change) - call void @__quantum__rt__callable_update_reference_count(%Callable* %2, i64 %count-change) - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %4 = load %Callable*, %Callable** %3 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %4, i64 %count-change) - call void @__quantum__rt__callable_update_reference_count(%Callable* %4, i64 %count-change) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %capture-tuple, i64 %count-change) - ret void -} - -define void @MemoryManagement__2__AliasCount(%Tuple* %capture-tuple, i64 %count-change) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %2 = load %Callable*, %Callable** %1 - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %2, i64 %count-change) - call void @__quantum__rt__callable_update_alias_count(%Callable* %2, i64 %count-change) - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %4 = load %Callable*, %Callable** %3 - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %4, i64 %count-change) - call void @__quantum__rt__callable_update_alias_count(%Callable* %4, i64 %count-change) - call void @__quantum__rt__tuple_update_alias_count(%Tuple* %capture-tuple, i64 %count-change) - ret void -} - -declare void @__quantum__rt__callable_update_reference_count(%Callable*, i64) - -define { %String* }* @Microsoft__Quantum__Targeting__TargetInstruction__body(%String* %__Item1__) { -entry: - %0 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64)) - %1 = bitcast %Tuple* %0 to { %String* }* - %2 = getelementptr inbounds { %String* }, { %String* }* %1, i32 0, i32 0 - store %String* %__Item1__, %String** %2 - call void @__quantum__rt__string_update_reference_count(%String* %__Item1__, i64 1) - ret { %String* }* %1 -} - -declare void @__quantum__rt__string_update_reference_count(%String*, i64) - -declare void @__quantum__rt__tuple_update_alias_count(%Tuple*, i64) diff --git a/src/QirRuntime/test/QIR-tracer/tracer-qir-win.ll b/src/QirRuntime/test/QIR-tracer/tracer-qir-win.ll deleted file mode 100644 index c53abaa2d2e..00000000000 --- a/src/QirRuntime/test/QIR-tracer/tracer-qir-win.ll +++ /dev/null @@ -1,2019 +0,0 @@ - -%Result = type opaque -%Range = type { i64, i64, i64 } -%Tuple = type opaque -%Array = type opaque -%Callable = type opaque -%Qubit = type opaque -%String = type opaque - -@ResultZero = external dllimport global %Result* -@ResultOne = external dllimport global %Result* -@PauliI = constant i2 0 -@PauliX = constant i2 1 -@PauliY = constant i2 -1 -@PauliZ = constant i2 -2 -@EmptyRange = internal constant %Range { i64 0, i64 1, i64 -1 } -@Microsoft__Quantum__Testing__Tracer__Delay = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Testing__Tracer__Delay__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null] -@Microsoft__Quantum__Intrinsic__X = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__X__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__X__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__X__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__X__ctladj__wrapper] -@PartialApplication__1 = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Lifted__PartialApplication__1__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null] -@MemoryManagement__1 = constant [2 x void (%Tuple*, i64)*] [void (%Tuple*, i64)* @MemoryManagement__1__RefCount, void (%Tuple*, i64)* @MemoryManagement__1__AliasCount] -@Microsoft__Quantum__Intrinsic__Y = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Y__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Y__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Y__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Y__ctladj__wrapper] -@PartialApplication__2 = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Lifted__PartialApplication__2__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null] -@Microsoft__Quantum__Intrinsic__Z = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Z__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Z__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Z__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__Z__ctladj__wrapper] -@PartialApplication__3 = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Lifted__PartialApplication__3__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null] -@Microsoft__Quantum__Intrinsic__S = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__S__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__S__adj__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__S__ctl__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* @Microsoft__Quantum__Intrinsic__S__ctladj__wrapper] -@PartialApplication__4 = constant [4 x void (%Tuple*, %Tuple*, %Tuple*)*] [void (%Tuple*, %Tuple*, %Tuple*)* @Lifted__PartialApplication__4__body__wrapper, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null, void (%Tuple*, %Tuple*, %Tuple*)* null] -@MemoryManagement__2 = constant [2 x void (%Tuple*, i64)*] [void (%Tuple*, i64)* @MemoryManagement__2__RefCount, void (%Tuple*, i64)* @MemoryManagement__2__AliasCount] - -define void @Microsoft__Quantum__Intrinsic__ApplyConditionallyIntrinsic__body(%Array* %measurementResults, %Array* %resultsValues, %Callable* %onEqualOp, %Callable* %onNonEqualOp) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %measurementResults, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %resultsValues, i64 1) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onEqualOp, i64 1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onEqualOp, i64 1) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onNonEqualOp, i64 1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onNonEqualOp, i64 1) - call void @__quantum__qis__apply_conditionally(%Array* %measurementResults, %Array* %resultsValues, %Callable* %onEqualOp, %Callable* %onNonEqualOp) - call void @__quantum__rt__array_update_alias_count(%Array* %measurementResults, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %resultsValues, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onEqualOp, i64 -1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onEqualOp, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onNonEqualOp, i64 -1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onNonEqualOp, i64 -1) - ret void -} - -declare void @__quantum__rt__array_update_alias_count(%Array*, i64) - -declare void @__quantum__rt__callable_memory_management(i32, %Callable*, i64) - -declare void @__quantum__rt__callable_update_alias_count(%Callable*, i64) - -declare void @__quantum__qis__apply_conditionally(%Array*, %Array*, %Callable*, %Callable*) - -define void @Microsoft__Quantum__Intrinsic__ApplyIfElseIntrinsic__body(%Result* %measurementResult, %Callable* %onResultZeroOp, %Callable* %onResultOneOp) { -entry: - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onResultZeroOp, i64 1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onResultZeroOp, i64 1) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onResultOneOp, i64 1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onResultOneOp, i64 1) - %0 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %1 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %0, i64 0) - %2 = bitcast i8* %1 to %Result** - store %Result* %measurementResult, %Result** %2 - %3 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %4 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %3, i64 0) - %5 = bitcast i8* %4 to %Result** - %6 = load %Result*, %Result** @ResultZero - store %Result* %6, %Result** %5 - call void @__quantum__qis__apply_conditionally(%Array* %0, %Array* %3, %Callable* %onResultZeroOp, %Callable* %onResultOneOp) - call void @__quantum__rt__result_update_reference_count(%Result* %measurementResult, i64 1) - call void @__quantum__rt__result_update_reference_count(%Result* %6, i64 1) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onResultZeroOp, i64 -1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onResultZeroOp, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %onResultOneOp, i64 -1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %onResultOneOp, i64 -1) - br label %header__1 - -header__1: ; preds = %exiting__1, %entry - %7 = phi i64 [ 0, %entry ], [ %12, %exiting__1 ] - %8 = icmp sle i64 %7, 0 - br i1 %8, label %body__1, label %exit__1 - -body__1: ; preds = %header__1 - %9 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %0, i64 %7) - %10 = bitcast i8* %9 to %Result** - %11 = load %Result*, %Result** %10 - call void @__quantum__rt__result_update_reference_count(%Result* %11, i64 -1) - br label %exiting__1 - -exiting__1: ; preds = %body__1 - %12 = add i64 %7, 1 - br label %header__1 - -exit__1: ; preds = %header__1 - call void @__quantum__rt__array_update_reference_count(%Array* %0, i64 -1) - br label %header__2 - -header__2: ; preds = %exiting__2, %exit__1 - %13 = phi i64 [ 0, %exit__1 ], [ %18, %exiting__2 ] - %14 = icmp sle i64 %13, 0 - br i1 %14, label %body__2, label %exit__2 - -body__2: ; preds = %header__2 - %15 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %3, i64 %13) - %16 = bitcast i8* %15 to %Result** - %17 = load %Result*, %Result** %16 - call void @__quantum__rt__result_update_reference_count(%Result* %17, i64 -1) - br label %exiting__2 - -exiting__2: ; preds = %body__2 - %18 = add i64 %13, 1 - br label %header__2 - -exit__2: ; preds = %header__2 - call void @__quantum__rt__array_update_reference_count(%Array* %3, i64 -1) - ret void -} - -declare %Array* @__quantum__rt__array_create_1d(i32, i64) - -declare i8* @__quantum__rt__array_get_element_ptr_1d(%Array*, i64) - -declare void @__quantum__rt__result_update_reference_count(%Result*, i64) - -declare void @__quantum__rt__array_update_reference_count(%Array*, i64) - -define void @Microsoft__Quantum__Intrinsic__CNOT__body(%Qubit* %control, %Qubit* %target) { -entry: - %ctls = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %0 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls, i64 0) - %1 = bitcast i8* %0 to %Qubit** - store %Qubit* %control, %Qubit** %1 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - br i1 true, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 1, i64 1, %Array* %ctls, %Qubit* %target) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 2, i64 1, %Array* %ctls, %Qubit* %target) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls, i64 -1) - ret void -} - -declare void @__quantum__qis__single_qubit_op_ctl(i64, i64, %Array*, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__CNOT__adj(%Qubit* %control, %Qubit* %target) { -entry: - call void @Microsoft__Quantum__Intrinsic__CNOT__body(%Qubit* %control, %Qubit* %target) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__CNOT__ctl(%Array* %ctls, { %Qubit*, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %1 = getelementptr inbounds { %Qubit*, %Qubit* }, { %Qubit*, %Qubit* }* %0, i32 0, i32 0 - %control = load %Qubit*, %Qubit** %1 - %2 = getelementptr inbounds { %Qubit*, %Qubit* }, { %Qubit*, %Qubit* }* %0, i32 0, i32 1 - %target = load %Qubit*, %Qubit** %2 - %3 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %4 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %3, i64 0) - %5 = bitcast i8* %4 to %Qubit** - store %Qubit* %control, %Qubit** %5 - %ctls__1 = call %Array* @__quantum__rt__array_concatenate(%Array* %ctls, %Array* %3) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__1, i64 1) - %6 = call i64 @__quantum__rt__array_get_size_1d(%Array* %ctls__1) - %7 = icmp eq i64 %6, 1 - br i1 %7, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 1, i64 1, %Array* %ctls__1, %Qubit* %target) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 2, i64 1, %Array* %ctls__1, %Qubit* %target) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__1, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %3, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__1, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -declare %Array* @__quantum__rt__array_concatenate(%Array*, %Array*) - -declare i64 @__quantum__rt__array_get_size_1d(%Array*) - -define void @Microsoft__Quantum__Intrinsic__CNOT__ctladj(%Array* %__controlQubits__, { %Qubit*, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - %1 = getelementptr inbounds { %Qubit*, %Qubit* }, { %Qubit*, %Qubit* }* %0, i32 0, i32 0 - %control = load %Qubit*, %Qubit** %1 - %2 = getelementptr inbounds { %Qubit*, %Qubit* }, { %Qubit*, %Qubit* }* %0, i32 0, i32 1 - %target = load %Qubit*, %Qubit** %2 - %3 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 2)) - %4 = bitcast %Tuple* %3 to { %Qubit*, %Qubit* }* - %5 = getelementptr inbounds { %Qubit*, %Qubit* }, { %Qubit*, %Qubit* }* %4, i32 0, i32 0 - %6 = getelementptr inbounds { %Qubit*, %Qubit* }, { %Qubit*, %Qubit* }* %4, i32 0, i32 1 - store %Qubit* %control, %Qubit** %5 - store %Qubit* %target, %Qubit** %6 - call void @Microsoft__Quantum__Intrinsic__CNOT__ctl(%Array* %__controlQubits__, { %Qubit*, %Qubit* }* %4) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %3, i64 -1) - ret void -} - -declare %Tuple* @__quantum__rt__tuple_create(i64) - -declare void @__quantum__rt__tuple_update_reference_count(%Tuple*, i64) - -define void @Microsoft__Quantum__Intrinsic__H__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 9, i64 1, %Qubit* %qb) - ret void -} - -declare void @__quantum__qis__single_qubit_op(i64, i64, %Qubit*) - -define void @Microsoft__Quantum__Intrinsic__H__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 9, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__H__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 10, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__H__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 10, i64 1, %Array* %__controlQubits__, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -define %Result* @Microsoft__Quantum__Intrinsic__M__body(%Qubit* %qb) { -entry: - %0 = call %Result* @__quantum__qis__single_qubit_measure(i64 100, i64 1, %Qubit* %qb) - ret %Result* %0 -} - -declare %Result* @__quantum__qis__single_qubit_measure(i64, i64, %Qubit*) - -define %Result* @Microsoft__Quantum__Intrinsic__Measure__body(%Array* %paulis, %Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %0 = load %Result*, %Result** @ResultOne - %res = alloca %Result* - store %Result* %0, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %0, i64 1) - %haveY = alloca i1 - store i1 false, i1* %haveY - %1 = call i64 @__quantum__rt__array_get_size_1d(%Array* %paulis) - %2 = sub i64 %1, 1 - br label %header__1 - -header__1: ; preds = %exiting__1, %entry - %i = phi i64 [ 0, %entry ], [ %15, %exiting__1 ] - %3 = icmp sle i64 %i, %2 - br i1 %3, label %body__1, label %exit__1 - -body__1: ; preds = %header__1 - %4 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 %i) - %5 = bitcast i8* %4 to i2* - %6 = load i2, i2* %5 - %7 = load i2, i2* @PauliY - %8 = icmp eq i2 %6, %7 - %9 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 %i) - %10 = bitcast i8* %9 to i2* - %11 = load i2, i2* %10 - %12 = load i2, i2* @PauliI - %13 = icmp eq i2 %11, %12 - %14 = or i1 %8, %13 - br i1 %14, label %then0__1, label %continue__1 - -then0__1: ; preds = %body__1 - store i1 true, i1* %haveY - br label %continue__1 - -continue__1: ; preds = %then0__1, %body__1 - br label %exiting__1 - -exiting__1: ; preds = %continue__1 - %15 = add i64 %i, 1 - br label %header__1 - -exit__1: ; preds = %header__1 - %16 = load i1, i1* %haveY - br i1 %16, label %then0__2, label %test1__1 - -then0__2: ; preds = %exit__1 - %17 = call %Result* @__quantum__qis__joint_measure(i64 106, i64 1, %Array* %qubits) - call void @__quantum__rt__result_update_reference_count(%Result* %17, i64 1) - store %Result* %17, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %17, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %0, i64 -1) - br label %continue__2 - -test1__1: ; preds = %exit__1 - %18 = icmp sgt i64 %1, 2 - br i1 %18, label %then1__1, label %test2__1 - -then1__1: ; preds = %test1__1 - %19 = call %Result* @__quantum__qis__joint_measure(i64 107, i64 1, %Array* %qubits) - call void @__quantum__rt__result_update_reference_count(%Result* %19, i64 1) - %20 = load %Result*, %Result** %res - store %Result* %19, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %19, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %20, i64 -1) - br label %continue__2 - -test2__1: ; preds = %test1__1 - %21 = icmp eq i64 %1, 1 - br i1 %21, label %then2__1, label %test3__1 - -then2__1: ; preds = %test2__1 - %22 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %23 = bitcast i8* %22 to i2* - %24 = load i2, i2* %23 - %25 = load i2, i2* @PauliX - %26 = icmp eq i2 %24, %25 - br i1 %26, label %then0__3, label %else__1 - -then0__3: ; preds = %then2__1 - %27 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qubits, i64 0) - %28 = bitcast i8* %27 to %Qubit** - %qb = load %Qubit*, %Qubit** %28 - %29 = call %Result* @__quantum__qis__single_qubit_measure(i64 101, i64 1, %Qubit* %qb) - call void @__quantum__rt__result_update_reference_count(%Result* %29, i64 1) - %30 = load %Result*, %Result** %res - store %Result* %29, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %29, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %30, i64 -1) - br label %continue__3 - -else__1: ; preds = %then2__1 - %31 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qubits, i64 0) - %32 = bitcast i8* %31 to %Qubit** - %qb__1 = load %Qubit*, %Qubit** %32 - %33 = call %Result* @__quantum__qis__single_qubit_measure(i64 100, i64 1, %Qubit* %qb__1) - call void @__quantum__rt__result_update_reference_count(%Result* %33, i64 1) - %34 = load %Result*, %Result** %res - store %Result* %33, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %33, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %34, i64 -1) - br label %continue__3 - -continue__3: ; preds = %else__1, %then0__3 - br label %continue__2 - -test3__1: ; preds = %test2__1 - %35 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %36 = bitcast i8* %35 to i2* - %37 = load i2, i2* %36 - %38 = load i2, i2* @PauliX - %39 = icmp eq i2 %37, %38 - %40 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %41 = bitcast i8* %40 to i2* - %42 = load i2, i2* %41 - %43 = load i2, i2* @PauliX - %44 = icmp eq i2 %42, %43 - %45 = and i1 %39, %44 - br i1 %45, label %then3__1, label %test4__1 - -then3__1: ; preds = %test3__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %46 = call %Result* @__quantum__qis__joint_measure(i64 105, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %46, i64 1) - %47 = load %Result*, %Result** %res - store %Result* %46, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %46, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %47, i64 -1) - br label %continue__2 - -test4__1: ; preds = %test3__1 - %48 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %49 = bitcast i8* %48 to i2* - %50 = load i2, i2* %49 - %51 = load i2, i2* @PauliX - %52 = icmp eq i2 %50, %51 - %53 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %54 = bitcast i8* %53 to i2* - %55 = load i2, i2* %54 - %56 = load i2, i2* @PauliZ - %57 = icmp eq i2 %55, %56 - %58 = and i1 %52, %57 - br i1 %58, label %then4__1, label %test5__1 - -then4__1: ; preds = %test4__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %59 = call %Result* @__quantum__qis__joint_measure(i64 103, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %59, i64 1) - %60 = load %Result*, %Result** %res - store %Result* %59, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %59, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %60, i64 -1) - br label %continue__2 - -test5__1: ; preds = %test4__1 - %61 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %62 = bitcast i8* %61 to i2* - %63 = load i2, i2* %62 - %64 = load i2, i2* @PauliZ - %65 = icmp eq i2 %63, %64 - %66 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %67 = bitcast i8* %66 to i2* - %68 = load i2, i2* %67 - %69 = load i2, i2* @PauliX - %70 = icmp eq i2 %68, %69 - %71 = and i1 %65, %70 - br i1 %71, label %then5__1, label %test6__1 - -then5__1: ; preds = %test5__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %72 = call %Result* @__quantum__qis__joint_measure(i64 104, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %72, i64 1) - %73 = load %Result*, %Result** %res - store %Result* %72, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %72, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %73, i64 -1) - br label %continue__2 - -test6__1: ; preds = %test5__1 - %74 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %75 = bitcast i8* %74 to i2* - %76 = load i2, i2* %75 - %77 = load i2, i2* @PauliZ - %78 = icmp eq i2 %76, %77 - %79 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %80 = bitcast i8* %79 to i2* - %81 = load i2, i2* %80 - %82 = load i2, i2* @PauliZ - %83 = icmp eq i2 %81, %82 - %84 = and i1 %78, %83 - br i1 %84, label %then6__1, label %continue__2 - -then6__1: ; preds = %test6__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %85 = call %Result* @__quantum__qis__joint_measure(i64 102, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %85, i64 1) - %86 = load %Result*, %Result** %res - store %Result* %85, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %85, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %86, i64 -1) - br label %continue__2 - -continue__2: ; preds = %then6__1, %test6__1, %then5__1, %then4__1, %then3__1, %continue__3, %then1__1, %then0__2 - %87 = load %Result*, %Result** %res - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret %Result* %87 -} - -declare %Result* @__quantum__qis__joint_measure(i64, i64, %Array*) - -define void @Microsoft__Quantum__Intrinsic__Rx__body(double %theta, %Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 19, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Rx__adj(double %theta, %Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 19, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Rx__ctl(%Array* %ctls, { double, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %1 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 0 - %theta = load double, double* %1 - %2 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 1 - %qb = load %Qubit*, %Qubit** %2 - call void @__quantum__qis__single_qubit_op_ctl(i64 20, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Rx__ctladj(%Array* %ctls, { double, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %1 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 0 - %theta = load double, double* %1 - %2 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 1 - %qb = load %Qubit*, %Qubit** %2 - call void @__quantum__qis__single_qubit_op_ctl(i64 20, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Ry__body(double %theta, %Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 21, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Ry__adj(double %theta, %Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 21, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Ry__ctl(%Array* %ctls, { double, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %1 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 0 - %theta = load double, double* %1 - %2 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 1 - %qb = load %Qubit*, %Qubit** %2 - call void @__quantum__qis__single_qubit_op_ctl(i64 22, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Ry__ctladj(%Array* %ctls, { double, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %1 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 0 - %theta = load double, double* %1 - %2 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 1 - %qb = load %Qubit*, %Qubit** %2 - call void @__quantum__qis__single_qubit_op_ctl(i64 22, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Rz__body(double %theta, %Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 23, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Rz__adj(double %theta, %Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 23, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Rz__ctl(%Array* %ctls, { double, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %1 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 0 - %theta = load double, double* %1 - %2 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 1 - %qb = load %Qubit*, %Qubit** %2 - call void @__quantum__qis__single_qubit_op_ctl(i64 24, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Rz__ctladj(%Array* %ctls, { double, %Qubit* }* %0) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %1 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 0 - %theta = load double, double* %1 - %2 = getelementptr inbounds { double, %Qubit* }, { double, %Qubit* }* %0, i32 0, i32 1 - %qb = load %Qubit*, %Qubit** %2 - call void @__quantum__qis__single_qubit_op_ctl(i64 24, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 15, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 15, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 16, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__ctladj(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 16, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__T__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__T__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__T__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 12, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__T__ctladj(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 12, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 0, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 0, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %0 = call i64 @__quantum__rt__array_get_size_1d(%Array* %ctls) - %1 = icmp eq i64 %0, 1 - br i1 %1, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 1, i64 1, %Array* %ctls, %Qubit* %qb) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 2, i64 1, %Array* %ctls, %Qubit* %qb) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - %0 = call i64 @__quantum__rt__array_get_size_1d(%Array* %__controlQubits__) - %1 = icmp eq i64 %0, 1 - br i1 %1, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 1, i64 1, %Array* %__controlQubits__, %Qubit* %qb) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 2, i64 1, %Array* %__controlQubits__, %Qubit* %qb) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 3, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 3, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %0 = call i64 @__quantum__rt__array_get_size_1d(%Array* %ctls) - %1 = icmp eq i64 %0, 1 - br i1 %1, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 4, i64 1, %Array* %ctls, %Qubit* %qb) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 5, i64 1, %Array* %ctls, %Qubit* %qb) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - %0 = call i64 @__quantum__rt__array_get_size_1d(%Array* %__controlQubits__) - %1 = icmp eq i64 %0, 1 - br i1 %1, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 4, i64 1, %Array* %__controlQubits__, %Qubit* %qb) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 5, i64 1, %Array* %__controlQubits__, %Qubit* %qb) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 6, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 6, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %0 = call i64 @__quantum__rt__array_get_size_1d(%Array* %ctls) - %1 = icmp eq i64 %0, 1 - br i1 %1, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 7, i64 1, %Array* %ctls, %Qubit* %qb) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 8, i64 1, %Array* %ctls, %Qubit* %qb) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__ctladj(%Array* %__controlQubits__, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 1) - %0 = call i64 @__quantum__rt__array_get_size_1d(%Array* %__controlQubits__) - %1 = icmp eq i64 %0, 1 - br i1 %1, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 7, i64 1, %Array* %__controlQubits__, %Qubit* %qb) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 8, i64 1, %Array* %__controlQubits__, %Qubit* %qb) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i64 -1) - ret void -} - -define %Tuple* @Microsoft__Quantum__Core__Attribute__body() { -entry: - ret %Tuple* null -} - -define %Tuple* @Microsoft__Quantum__Core__EntryPoint__body() { -entry: - ret %Tuple* null -} - -define %Tuple* @Microsoft__Quantum__Core__Inline__body() { -entry: - ret %Tuple* null -} - -define %Result* @Microsoft__Quantum__Instructions__Mx__body(%Qubit* %qb) { -entry: - %0 = call %Result* @__quantum__qis__single_qubit_measure(i64 101, i64 1, %Qubit* %qb) - ret %Result* %0 -} - -define %Result* @Microsoft__Quantum__Instructions__Mxx__body(%Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %0 = call %Result* @__quantum__qis__joint_measure(i64 105, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret %Result* %0 -} - -define %Result* @Microsoft__Quantum__Instructions__Mxz__body(%Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %0 = call %Result* @__quantum__qis__joint_measure(i64 103, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret %Result* %0 -} - -define %Result* @Microsoft__Quantum__Instructions__Mz__body(%Qubit* %qb) { -entry: - %0 = call %Result* @__quantum__qis__single_qubit_measure(i64 100, i64 1, %Qubit* %qb) - ret %Result* %0 -} - -define %Result* @Microsoft__Quantum__Instructions__Mzx__body(%Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %0 = call %Result* @__quantum__qis__joint_measure(i64 104, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret %Result* %0 -} - -define %Result* @Microsoft__Quantum__Instructions__Mzz__body(%Array* %qubits) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 1) - %0 = call %Result* @__quantum__qis__joint_measure(i64 102, i64 1, %Array* %qubits) - call void @__quantum__rt__array_update_alias_count(%Array* %qubits, i64 -1) - ret %Result* %0 -} - -define void @Microsoft__Quantum__Instructions__Sx__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 17, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Sx__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 17, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Sx__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 18, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Instructions__Sx__ctladj(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 18, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Instructions__Sz__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 15, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Sz__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 15, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Sz__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 16, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Instructions__Sz__ctladj(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 16, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tx__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 13, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tx__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 13, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tx__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 14, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tx__ctladj(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 14, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tz__body(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tz__adj(%Qubit* %qb) { -entry: - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tz__ctl(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 12, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Instructions__Tz__ctladj(%Array* %ctls, %Qubit* %qb) { -entry: - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 12, i64 1, %Array* %ctls, %Qubit* %qb) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Testing__Tracer__Delay__body(%Callable* %op, %Qubit* %arg, %Tuple* %aux) { -entry: - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %op, i64 1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %op, i64 1) - %0 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64)) - %1 = bitcast %Tuple* %0 to { %Qubit* }* - %2 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %1, i32 0, i32 0 - store %Qubit* %arg, %Qubit** %2 - call void @__quantum__rt__callable_invoke(%Callable* %op, %Tuple* %0, %Tuple* null) - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %op, i64 -1) - call void @__quantum__rt__callable_update_alias_count(%Callable* %op, i64 -1) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %0, i64 -1) - ret void -} - -declare void @__quantum__rt__callable_invoke(%Callable*, %Tuple*, %Tuple*) - -define void @Microsoft__Quantum__Testing__Tracer__TestCoreIntrinsics__body() { -entry: - %qs = call %Array* @__quantum__rt__qubit_allocate_array(i64 3) - call void @__quantum__rt__array_update_alias_count(%Array* %qs, i64 1) - %0 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %1 = bitcast i8* %0 to %Qubit** - %qb = load %Qubit*, %Qubit** %1 - call void @__quantum__qis__single_qubit_op(i64 0, i64 1, %Qubit* %qb) - %2 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %3 = bitcast i8* %2 to %Qubit** - %qb__1 = load %Qubit*, %Qubit** %3 - call void @__quantum__qis__single_qubit_op(i64 3, i64 1, %Qubit* %qb__1) - %4 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %5 = bitcast i8* %4 to %Qubit** - %qb__2 = load %Qubit*, %Qubit** %5 - call void @__quantum__qis__single_qubit_op(i64 6, i64 1, %Qubit* %qb__2) - %6 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %7 = bitcast i8* %6 to %Qubit** - %qb__3 = load %Qubit*, %Qubit** %7 - call void @__quantum__qis__single_qubit_op(i64 9, i64 1, %Qubit* %qb__3) - %8 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %9 = bitcast i8* %8 to %Qubit** - %10 = load %Qubit*, %Qubit** %9 - %11 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %12 = bitcast i8* %11 to %Qubit** - %13 = load %Qubit*, %Qubit** %12 - call void @Microsoft__Quantum__Intrinsic__CNOT__body(%Qubit* %10, %Qubit* %13) - %14 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %15 = bitcast i8* %14 to %Qubit** - %qb__4 = load %Qubit*, %Qubit** %15 - call void @__quantum__qis__single_qubit_op(i64 19, i64 1, %Qubit* %qb__4) - %16 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %17 = bitcast i8* %16 to %Qubit** - %qb__5 = load %Qubit*, %Qubit** %17 - call void @__quantum__qis__single_qubit_op(i64 21, i64 1, %Qubit* %qb__5) - %18 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %19 = bitcast i8* %18 to %Qubit** - %qb__6 = load %Qubit*, %Qubit** %19 - call void @__quantum__qis__single_qubit_op(i64 23, i64 1, %Qubit* %qb__6) - %20 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %21 = bitcast i8* %20 to %Qubit** - %qb__7 = load %Qubit*, %Qubit** %21 - call void @__quantum__qis__single_qubit_op(i64 15, i64 1, %Qubit* %qb__7) - %22 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %23 = bitcast i8* %22 to %Qubit** - %qb__9 = load %Qubit*, %Qubit** %23 - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb__9) - call void @__quantum__qis__inject_barrier(i64 42, i64 0) - %24 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %25 = bitcast i8* %24 to %Qubit** - %qb__11 = load %Qubit*, %Qubit** %25 - call void @__quantum__qis__single_qubit_op(i64 0, i64 1, %Qubit* %qb__11) - %26 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %27 = bitcast i8* %26 to %Qubit** - %qb__13 = load %Qubit*, %Qubit** %27 - call void @__quantum__qis__single_qubit_op(i64 3, i64 1, %Qubit* %qb__13) - %28 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %29 = bitcast i8* %28 to %Qubit** - %qb__15 = load %Qubit*, %Qubit** %29 - call void @__quantum__qis__single_qubit_op(i64 6, i64 1, %Qubit* %qb__15) - %30 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %31 = bitcast i8* %30 to %Qubit** - %qb__17 = load %Qubit*, %Qubit** %31 - call void @__quantum__qis__single_qubit_op(i64 9, i64 1, %Qubit* %qb__17) - %32 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %33 = bitcast i8* %32 to %Qubit** - %34 = load %Qubit*, %Qubit** %33 - %35 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %36 = bitcast i8* %35 to %Qubit** - %37 = load %Qubit*, %Qubit** %36 - call void @Microsoft__Quantum__Intrinsic__CNOT__adj(%Qubit* %34, %Qubit* %37) - %38 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %39 = bitcast i8* %38 to %Qubit** - %qb__19 = load %Qubit*, %Qubit** %39 - call void @__quantum__qis__single_qubit_op(i64 19, i64 1, %Qubit* %qb__19) - %40 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %41 = bitcast i8* %40 to %Qubit** - %qb__20 = load %Qubit*, %Qubit** %41 - call void @__quantum__qis__single_qubit_op(i64 21, i64 1, %Qubit* %qb__20) - %42 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %43 = bitcast i8* %42 to %Qubit** - %qb__21 = load %Qubit*, %Qubit** %43 - call void @__quantum__qis__single_qubit_op(i64 23, i64 1, %Qubit* %qb__21) - %44 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %45 = bitcast i8* %44 to %Qubit** - %qb__22 = load %Qubit*, %Qubit** %45 - call void @__quantum__qis__single_qubit_op(i64 15, i64 1, %Qubit* %qb__22) - %46 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %47 = bitcast i8* %46 to %Qubit** - %qb__24 = load %Qubit*, %Qubit** %47 - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb__24) - %c = call %Qubit* @__quantum__rt__qubit_allocate() - %ctls = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %48 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls, i64 0) - %49 = bitcast i8* %48 to %Qubit** - store %Qubit* %c, %Qubit** %49 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 1) - %50 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %51 = bitcast i8* %50 to %Qubit** - %qb__26 = load %Qubit*, %Qubit** %51 - br i1 true, label %then0__1, label %else__1 - -then0__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 1, i64 1, %Array* %ctls, %Qubit* %qb__26) - br label %continue__1 - -else__1: ; preds = %entry - call void @__quantum__qis__single_qubit_op_ctl(i64 2, i64 1, %Array* %ctls, %Qubit* %qb__26) - br label %continue__1 - -continue__1: ; preds = %else__1, %then0__1 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls, i64 -1) - %ctls__1 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %52 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__1, i64 0) - %53 = bitcast i8* %52 to %Qubit** - store %Qubit* %c, %Qubit** %53 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__1, i64 1) - %54 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %55 = bitcast i8* %54 to %Qubit** - %qb__27 = load %Qubit*, %Qubit** %55 - br i1 true, label %then0__2, label %else__2 - -then0__2: ; preds = %continue__1 - call void @__quantum__qis__single_qubit_op_ctl(i64 4, i64 1, %Array* %ctls__1, %Qubit* %qb__27) - br label %continue__2 - -else__2: ; preds = %continue__1 - call void @__quantum__qis__single_qubit_op_ctl(i64 5, i64 1, %Array* %ctls__1, %Qubit* %qb__27) - br label %continue__2 - -continue__2: ; preds = %else__2, %then0__2 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__1, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__1, i64 -1) - %ctls__2 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %56 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__2, i64 0) - %57 = bitcast i8* %56 to %Qubit** - store %Qubit* %c, %Qubit** %57 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__2, i64 1) - %58 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %59 = bitcast i8* %58 to %Qubit** - %qb__28 = load %Qubit*, %Qubit** %59 - br i1 true, label %then0__3, label %else__3 - -then0__3: ; preds = %continue__2 - call void @__quantum__qis__single_qubit_op_ctl(i64 7, i64 1, %Array* %ctls__2, %Qubit* %qb__28) - br label %continue__3 - -else__3: ; preds = %continue__2 - call void @__quantum__qis__single_qubit_op_ctl(i64 8, i64 1, %Array* %ctls__2, %Qubit* %qb__28) - br label %continue__3 - -continue__3: ; preds = %else__3, %then0__3 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__2, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__2, i64 -1) - %ctls__3 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %60 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__3, i64 0) - %61 = bitcast i8* %60 to %Qubit** - store %Qubit* %c, %Qubit** %61 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__3, i64 1) - %62 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %63 = bitcast i8* %62 to %Qubit** - %qb__29 = load %Qubit*, %Qubit** %63 - call void @__quantum__qis__single_qubit_op_ctl(i64 10, i64 1, %Array* %ctls__3, %Qubit* %qb__29) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__3, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__3, i64 -1) - %ctls__4 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %64 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__4, i64 0) - %65 = bitcast i8* %64 to %Qubit** - store %Qubit* %c, %Qubit** %65 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__4, i64 1) - %66 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %67 = bitcast i8* %66 to %Qubit** - %qb__30 = load %Qubit*, %Qubit** %67 - call void @__quantum__qis__single_qubit_op_ctl(i64 20, i64 1, %Array* %ctls__4, %Qubit* %qb__30) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__4, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__4, i64 -1) - %ctls__5 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %68 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__5, i64 0) - %69 = bitcast i8* %68 to %Qubit** - store %Qubit* %c, %Qubit** %69 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__5, i64 1) - %70 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %71 = bitcast i8* %70 to %Qubit** - %qb__31 = load %Qubit*, %Qubit** %71 - call void @__quantum__qis__single_qubit_op_ctl(i64 22, i64 1, %Array* %ctls__5, %Qubit* %qb__31) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__5, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__5, i64 -1) - %ctls__6 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %72 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__6, i64 0) - %73 = bitcast i8* %72 to %Qubit** - store %Qubit* %c, %Qubit** %73 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__6, i64 1) - %74 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %75 = bitcast i8* %74 to %Qubit** - %qb__32 = load %Qubit*, %Qubit** %75 - call void @__quantum__qis__single_qubit_op_ctl(i64 24, i64 1, %Array* %ctls__6, %Qubit* %qb__32) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__6, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__6, i64 -1) - %ctls__7 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %76 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__7, i64 0) - %77 = bitcast i8* %76 to %Qubit** - store %Qubit* %c, %Qubit** %77 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__7, i64 1) - %78 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %79 = bitcast i8* %78 to %Qubit** - %qb__33 = load %Qubit*, %Qubit** %79 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__7, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 16, i64 1, %Array* %ctls__7, %Qubit* %qb__33) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__7, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__7, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__7, i64 -1) - %ctls__9 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 1) - %80 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %ctls__9, i64 0) - %81 = bitcast i8* %80 to %Qubit** - store %Qubit* %c, %Qubit** %81 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__9, i64 1) - %82 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %83 = bitcast i8* %82 to %Qubit** - %qb__35 = load %Qubit*, %Qubit** %83 - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__9, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 12, i64 1, %Array* %ctls__9, %Qubit* %qb__35) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__9, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %ctls__9, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %ctls__9, i64 -1) - call void @__quantum__rt__qubit_release(%Qubit* %c) - %cc = call %Array* @__quantum__rt__qubit_allocate_array(i64 2) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %84 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %85 = bitcast i8* %84 to %Qubit** - %qb__37 = load %Qubit*, %Qubit** %85 - %86 = call i64 @__quantum__rt__array_get_size_1d(%Array* %cc) - %87 = icmp eq i64 %86, 1 - br i1 %87, label %then0__4, label %else__4 - -then0__4: ; preds = %continue__3 - call void @__quantum__qis__single_qubit_op_ctl(i64 1, i64 1, %Array* %cc, %Qubit* %qb__37) - br label %continue__4 - -else__4: ; preds = %continue__3 - call void @__quantum__qis__single_qubit_op_ctl(i64 2, i64 1, %Array* %cc, %Qubit* %qb__37) - br label %continue__4 - -continue__4: ; preds = %else__4, %then0__4 - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %88 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %89 = bitcast i8* %88 to %Qubit** - %qb__38 = load %Qubit*, %Qubit** %89 - %90 = icmp eq i64 %86, 1 - br i1 %90, label %then0__5, label %else__5 - -then0__5: ; preds = %continue__4 - call void @__quantum__qis__single_qubit_op_ctl(i64 4, i64 1, %Array* %cc, %Qubit* %qb__38) - br label %continue__5 - -else__5: ; preds = %continue__4 - call void @__quantum__qis__single_qubit_op_ctl(i64 5, i64 1, %Array* %cc, %Qubit* %qb__38) - br label %continue__5 - -continue__5: ; preds = %else__5, %then0__5 - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %91 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %92 = bitcast i8* %91 to %Qubit** - %qb__39 = load %Qubit*, %Qubit** %92 - %93 = icmp eq i64 %86, 1 - br i1 %93, label %then0__6, label %else__6 - -then0__6: ; preds = %continue__5 - call void @__quantum__qis__single_qubit_op_ctl(i64 7, i64 1, %Array* %cc, %Qubit* %qb__39) - br label %continue__6 - -else__6: ; preds = %continue__5 - call void @__quantum__qis__single_qubit_op_ctl(i64 8, i64 1, %Array* %cc, %Qubit* %qb__39) - br label %continue__6 - -continue__6: ; preds = %else__6, %then0__6 - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %94 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %95 = bitcast i8* %94 to %Qubit** - %qb__40 = load %Qubit*, %Qubit** %95 - call void @__quantum__qis__single_qubit_op_ctl(i64 10, i64 1, %Array* %cc, %Qubit* %qb__40) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %96 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %97 = bitcast i8* %96 to %Qubit** - %qb__41 = load %Qubit*, %Qubit** %97 - call void @__quantum__qis__single_qubit_op_ctl(i64 20, i64 1, %Array* %cc, %Qubit* %qb__41) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %98 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %99 = bitcast i8* %98 to %Qubit** - %qb__42 = load %Qubit*, %Qubit** %99 - call void @__quantum__qis__single_qubit_op_ctl(i64 22, i64 1, %Array* %cc, %Qubit* %qb__42) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %100 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %101 = bitcast i8* %100 to %Qubit** - %qb__43 = load %Qubit*, %Qubit** %101 - call void @__quantum__qis__single_qubit_op_ctl(i64 24, i64 1, %Array* %cc, %Qubit* %qb__43) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %102 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %103 = bitcast i8* %102 to %Qubit** - %qb__44 = load %Qubit*, %Qubit** %103 - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 16, i64 1, %Array* %cc, %Qubit* %qb__44) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - %104 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %105 = bitcast i8* %104 to %Qubit** - %qb__46 = load %Qubit*, %Qubit** %105 - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 1) - call void @__quantum__qis__single_qubit_op_ctl(i64 12, i64 1, %Array* %cc, %Qubit* %qb__46) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__qubit_release_array(%Array* %cc) - call void @__quantum__rt__array_update_alias_count(%Array* %cc, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %cc, i64 -1) - call void @__quantum__rt__qubit_release_array(%Array* %qs) - call void @__quantum__rt__array_update_alias_count(%Array* %qs, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %qs, i64 -1) - ret void -} - -declare %Qubit* @__quantum__rt__qubit_allocate() - -declare %Array* @__quantum__rt__qubit_allocate_array(i64) - -declare void @__quantum__qis__inject_barrier(i64, i64) - -declare void @__quantum__rt__qubit_release(%Qubit*) - -declare void @__quantum__rt__qubit_release_array(%Array*) - -define void @Microsoft__Quantum__Testing__Tracer__TestMeasurements__body() { -entry: - %qs = call %Array* @__quantum__rt__qubit_allocate_array(i64 6) - call void @__quantum__rt__array_update_alias_count(%Array* %qs, i64 1) - %0 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %1 = bitcast i8* %0 to %Qubit** - %qb = load %Qubit*, %Qubit** %1 - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb) - %2 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 0) - %3 = bitcast i8* %2 to %Qubit** - %qb__2 = load %Qubit*, %Qubit** %3 - %r0 = call %Result* @__quantum__qis__single_qubit_measure(i64 100, i64 1, %Qubit* %qb__2) - %4 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %5 = bitcast i8* %4 to %Qubit** - %qb__4 = load %Qubit*, %Qubit** %5 - call void @__quantum__qis__single_qubit_op(i64 11, i64 1, %Qubit* %qb__4) - %6 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %7 = bitcast i8* %6 to %Qubit** - %8 = load %Qubit*, %Qubit** %7 - %9 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %10 = bitcast i8* %9 to %Qubit** - %11 = load %Qubit*, %Qubit** %10 - call void @Microsoft__Quantum__Intrinsic__CNOT__body(%Qubit* %8, %Qubit* %11) - %qs12 = call %Array* @__quantum__rt__array_create_1d(i32 8, i64 2) - %12 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs12, i64 0) - %13 = bitcast i8* %12 to %Qubit** - %14 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs12, i64 1) - %15 = bitcast i8* %14 to %Qubit** - %16 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 1) - %17 = bitcast i8* %16 to %Qubit** - %18 = load %Qubit*, %Qubit** %17 - %19 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 2) - %20 = bitcast i8* %19 to %Qubit** - %21 = load %Qubit*, %Qubit** %20 - store %Qubit* %18, %Qubit** %13 - store %Qubit* %21, %Qubit** %15 - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 1) - %paulis = call %Array* @__quantum__rt__array_create_1d(i32 1, i64 2) - %22 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %23 = bitcast i8* %22 to i2* - %24 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %25 = bitcast i8* %24 to i2* - %26 = load i2, i2* @PauliY - %27 = load i2, i2* @PauliX - store i2 %26, i2* %23 - store i2 %27, i2* %25 - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 1) - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 1) - %28 = load %Result*, %Result** @ResultOne - %res = alloca %Result* - store %Result* %28, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %28, i64 1) - %haveY = alloca i1 - store i1 false, i1* %haveY - br label %header__1 - -header__1: ; preds = %exiting__1, %entry - %i = phi i64 [ 0, %entry ], [ %41, %exiting__1 ] - %29 = icmp sle i64 %i, 1 - br i1 %29, label %body__1, label %exit__1 - -body__1: ; preds = %header__1 - %30 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 %i) - %31 = bitcast i8* %30 to i2* - %32 = load i2, i2* %31 - %33 = load i2, i2* @PauliY - %34 = icmp eq i2 %32, %33 - %35 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 %i) - %36 = bitcast i8* %35 to i2* - %37 = load i2, i2* %36 - %38 = load i2, i2* @PauliI - %39 = icmp eq i2 %37, %38 - %40 = or i1 %34, %39 - br i1 %40, label %then0__1, label %continue__1 - -then0__1: ; preds = %body__1 - store i1 true, i1* %haveY - br label %continue__1 - -continue__1: ; preds = %then0__1, %body__1 - br label %exiting__1 - -exiting__1: ; preds = %continue__1 - %41 = add i64 %i, 1 - br label %header__1 - -exit__1: ; preds = %header__1 - %42 = load i1, i1* %haveY - br i1 %42, label %then0__2, label %test1__1 - -then0__2: ; preds = %exit__1 - %43 = call %Result* @__quantum__qis__joint_measure(i64 106, i64 1, %Array* %qs12) - call void @__quantum__rt__result_update_reference_count(%Result* %43, i64 1) - store %Result* %43, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %43, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %28, i64 -1) - br label %continue__2 - -test1__1: ; preds = %exit__1 - br i1 false, label %then1__1, label %test2__1 - -then1__1: ; preds = %test1__1 - %44 = call %Result* @__quantum__qis__joint_measure(i64 107, i64 1, %Array* %qs12) - call void @__quantum__rt__result_update_reference_count(%Result* %44, i64 1) - %45 = load %Result*, %Result** %res - store %Result* %44, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %44, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %45, i64 -1) - br label %continue__2 - -test2__1: ; preds = %test1__1 - br i1 false, label %then2__1, label %test3__1 - -then2__1: ; preds = %test2__1 - %46 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %47 = bitcast i8* %46 to i2* - %48 = load i2, i2* %47 - %49 = load i2, i2* @PauliX - %50 = icmp eq i2 %48, %49 - br i1 %50, label %then0__3, label %else__1 - -then0__3: ; preds = %then2__1 - %51 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs12, i64 0) - %52 = bitcast i8* %51 to %Qubit** - %qb__6 = load %Qubit*, %Qubit** %52 - %53 = call %Result* @__quantum__qis__single_qubit_measure(i64 101, i64 1, %Qubit* %qb__6) - call void @__quantum__rt__result_update_reference_count(%Result* %53, i64 1) - %54 = load %Result*, %Result** %res - store %Result* %53, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %53, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %54, i64 -1) - br label %continue__3 - -else__1: ; preds = %then2__1 - %55 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs12, i64 0) - %56 = bitcast i8* %55 to %Qubit** - %qb__7 = load %Qubit*, %Qubit** %56 - %57 = call %Result* @__quantum__qis__single_qubit_measure(i64 100, i64 1, %Qubit* %qb__7) - call void @__quantum__rt__result_update_reference_count(%Result* %57, i64 1) - %58 = load %Result*, %Result** %res - store %Result* %57, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %57, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %58, i64 -1) - br label %continue__3 - -continue__3: ; preds = %else__1, %then0__3 - br label %continue__2 - -test3__1: ; preds = %test2__1 - %59 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %60 = bitcast i8* %59 to i2* - %61 = load i2, i2* %60 - %62 = load i2, i2* @PauliX - %63 = icmp eq i2 %61, %62 - %64 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %65 = bitcast i8* %64 to i2* - %66 = load i2, i2* %65 - %67 = load i2, i2* @PauliX - %68 = icmp eq i2 %66, %67 - %69 = and i1 %63, %68 - br i1 %69, label %then3__1, label %test4__1 - -then3__1: ; preds = %test3__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 1) - %70 = call %Result* @__quantum__qis__joint_measure(i64 105, i64 1, %Array* %qs12) - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %70, i64 1) - %71 = load %Result*, %Result** %res - store %Result* %70, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %70, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %71, i64 -1) - br label %continue__2 - -test4__1: ; preds = %test3__1 - %72 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %73 = bitcast i8* %72 to i2* - %74 = load i2, i2* %73 - %75 = load i2, i2* @PauliX - %76 = icmp eq i2 %74, %75 - %77 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %78 = bitcast i8* %77 to i2* - %79 = load i2, i2* %78 - %80 = load i2, i2* @PauliZ - %81 = icmp eq i2 %79, %80 - %82 = and i1 %76, %81 - br i1 %82, label %then4__1, label %test5__1 - -then4__1: ; preds = %test4__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 1) - %83 = call %Result* @__quantum__qis__joint_measure(i64 103, i64 1, %Array* %qs12) - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %83, i64 1) - %84 = load %Result*, %Result** %res - store %Result* %83, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %83, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %84, i64 -1) - br label %continue__2 - -test5__1: ; preds = %test4__1 - %85 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %86 = bitcast i8* %85 to i2* - %87 = load i2, i2* %86 - %88 = load i2, i2* @PauliZ - %89 = icmp eq i2 %87, %88 - %90 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %91 = bitcast i8* %90 to i2* - %92 = load i2, i2* %91 - %93 = load i2, i2* @PauliX - %94 = icmp eq i2 %92, %93 - %95 = and i1 %89, %94 - br i1 %95, label %then5__1, label %test6__1 - -then5__1: ; preds = %test5__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 1) - %96 = call %Result* @__quantum__qis__joint_measure(i64 104, i64 1, %Array* %qs12) - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %96, i64 1) - %97 = load %Result*, %Result** %res - store %Result* %96, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %96, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %97, i64 -1) - br label %continue__2 - -test6__1: ; preds = %test5__1 - %98 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 0) - %99 = bitcast i8* %98 to i2* - %100 = load i2, i2* %99 - %101 = load i2, i2* @PauliZ - %102 = icmp eq i2 %100, %101 - %103 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %paulis, i64 1) - %104 = bitcast i8* %103 to i2* - %105 = load i2, i2* %104 - %106 = load i2, i2* @PauliZ - %107 = icmp eq i2 %105, %106 - %108 = and i1 %102, %107 - br i1 %108, label %then6__1, label %continue__2 - -then6__1: ; preds = %test6__1 - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 1) - %109 = call %Result* @__quantum__qis__joint_measure(i64 102, i64 1, %Array* %qs12) - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %109, i64 1) - %110 = load %Result*, %Result** %res - store %Result* %109, %Result** %res - call void @__quantum__rt__result_update_reference_count(%Result* %109, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %110, i64 -1) - br label %continue__2 - -continue__2: ; preds = %then6__1, %test6__1, %then5__1, %then4__1, %then3__1, %continue__3, %then1__1, %then0__2 - %r12 = load %Result*, %Result** %res - call void @__quantum__rt__array_update_alias_count(%Array* %paulis, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %paulis, i64 -1) - %111 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %112 = bitcast %Tuple* %111 to { %Callable*, %Callable*, %Qubit* }* - %113 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %112, i32 0, i32 0 - %114 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %112, i32 0, i32 1 - %115 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %112, i32 0, i32 2 - %116 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Testing__Tracer__Delay, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %117 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__X, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %118 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 3) - %119 = bitcast i8* %118 to %Qubit** - %120 = load %Qubit*, %Qubit** %119 - store %Callable* %116, %Callable** %113 - store %Callable* %117, %Callable** %114 - store %Qubit* %120, %Qubit** %115 - %121 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @PartialApplication__1, [2 x void (%Tuple*, i64)*]* @MemoryManagement__1, %Tuple* %111) - %122 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %123 = bitcast %Tuple* %122 to { %Callable*, %Callable*, %Qubit* }* - %124 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %123, i32 0, i32 0 - %125 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %123, i32 0, i32 1 - %126 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %123, i32 0, i32 2 - %127 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Testing__Tracer__Delay, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %128 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__Y, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %129 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 3) - %130 = bitcast i8* %129 to %Qubit** - %131 = load %Qubit*, %Qubit** %130 - store %Callable* %127, %Callable** %124 - store %Callable* %128, %Callable** %125 - store %Qubit* %131, %Qubit** %126 - %132 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @PartialApplication__2, [2 x void (%Tuple*, i64)*]* @MemoryManagement__1, %Tuple* %122) - call void @Microsoft__Quantum__Intrinsic__ApplyIfElseIntrinsic__body(%Result* %r0, %Callable* %121, %Callable* %132) - %133 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %134 = bitcast %Tuple* %133 to { %Callable*, %Callable*, %Qubit* }* - %135 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %134, i32 0, i32 0 - %136 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %134, i32 0, i32 1 - %137 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %134, i32 0, i32 2 - %138 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Testing__Tracer__Delay, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %139 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__Z, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %140 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 4) - %141 = bitcast i8* %140 to %Qubit** - %142 = load %Qubit*, %Qubit** %141 - store %Callable* %138, %Callable** %135 - store %Callable* %139, %Callable** %136 - store %Qubit* %142, %Qubit** %137 - %143 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @PartialApplication__3, [2 x void (%Tuple*, i64)*]* @MemoryManagement__1, %Tuple* %133) - %144 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %145 = bitcast %Tuple* %144 to { %Callable*, %Callable*, %Qubit* }* - %146 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %145, i32 0, i32 0 - %147 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %145, i32 0, i32 1 - %148 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %145, i32 0, i32 2 - %149 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Testing__Tracer__Delay, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %150 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @Microsoft__Quantum__Intrinsic__S, [2 x void (%Tuple*, i64)*]* null, %Tuple* null) - %151 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 4) - %152 = bitcast i8* %151 to %Qubit** - %153 = load %Qubit*, %Qubit** %152 - store %Callable* %149, %Callable** %146 - store %Callable* %150, %Callable** %147 - store %Qubit* %153, %Qubit** %148 - %154 = call %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]* @PartialApplication__4, [2 x void (%Tuple*, i64)*]* @MemoryManagement__2, %Tuple* %144) - call void @Microsoft__Quantum__Intrinsic__ApplyIfElseIntrinsic__body(%Result* %r12, %Callable* %143, %Callable* %154) - %155 = call i8* @__quantum__rt__array_get_element_ptr_1d(%Array* %qs, i64 5) - %156 = bitcast i8* %155 to %Qubit** - %qb__8 = load %Qubit*, %Qubit** %156 - call void @__quantum__qis__single_qubit_op(i64 19, i64 1, %Qubit* %qb__8) - call void @__quantum__rt__qubit_release_array(%Array* %qs) - call void @__quantum__rt__array_update_alias_count(%Array* %qs, i64 -1) - call void @__quantum__rt__array_update_alias_count(%Array* %qs12, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %qs, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %r0, i64 -1) - call void @__quantum__rt__array_update_reference_count(%Array* %qs12, i64 -1) - call void @__quantum__rt__result_update_reference_count(%Result* %r12, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %121, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %121, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %132, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %132, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %143, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %143, i64 -1) - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %154, i64 -1) - call void @__quantum__rt__callable_update_reference_count(%Callable* %154, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Testing__Tracer__Delay__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Callable*, %Qubit*, %Tuple* }* - %1 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %0, i32 0, i32 1 - %3 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %0, i32 0, i32 2 - %4 = load %Callable*, %Callable** %1 - %5 = load %Qubit*, %Qubit** %2 - %6 = load %Tuple*, %Tuple** %3 - call void @Microsoft__Quantum__Testing__Tracer__Delay__body(%Callable* %4, %Qubit* %5, %Tuple* %6) - ret void -} - -declare %Callable* @__quantum__rt__callable_create([4 x void (%Tuple*, %Tuple*, %Tuple*)*]*, [2 x void (%Tuple*, i64)*]*, %Tuple*) - -define void @Microsoft__Quantum__Intrinsic__X__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__X__body(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__X__adj(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__X__ctl(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__X__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__X__ctladj(%Array* %3, %Qubit* %4) - ret void -} - -define void @Lifted__PartialApplication__1__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %2 = load %Callable*, %Callable** %1 - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 2 - %4 = load %Qubit*, %Qubit** %3 - %5 = bitcast %Tuple* %arg-tuple to { %Tuple* }* - %6 = getelementptr inbounds { %Tuple* }, { %Tuple* }* %5, i32 0, i32 0 - %7 = load %Tuple*, %Tuple** %6 - %8 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %9 = bitcast %Tuple* %8 to { %Callable*, %Qubit*, %Tuple* }* - %10 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 0 - %11 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 1 - %12 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 2 - store %Callable* %2, %Callable** %10 - store %Qubit* %4, %Qubit** %11 - store %Tuple* %7, %Tuple** %12 - %13 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %14 = load %Callable*, %Callable** %13 - call void @__quantum__rt__callable_invoke(%Callable* %14, %Tuple* %8, %Tuple* %result-tuple) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %8, i64 -1) - ret void -} - -define void @MemoryManagement__1__RefCount(%Tuple* %capture-tuple, i64 %count-change) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %2 = load %Callable*, %Callable** %1 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %2, i64 %count-change) - call void @__quantum__rt__callable_update_reference_count(%Callable* %2, i64 %count-change) - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %4 = load %Callable*, %Callable** %3 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %4, i64 %count-change) - call void @__quantum__rt__callable_update_reference_count(%Callable* %4, i64 %count-change) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %capture-tuple, i64 %count-change) - ret void -} - -define void @MemoryManagement__1__AliasCount(%Tuple* %capture-tuple, i64 %count-change) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %2 = load %Callable*, %Callable** %1 - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %2, i64 %count-change) - call void @__quantum__rt__callable_update_alias_count(%Callable* %2, i64 %count-change) - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %4 = load %Callable*, %Callable** %3 - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %4, i64 %count-change) - call void @__quantum__rt__callable_update_alias_count(%Callable* %4, i64 %count-change) - call void @__quantum__rt__tuple_update_alias_count(%Tuple* %capture-tuple, i64 %count-change) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__Y__body(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__Y__adj(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__Y__ctl(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Y__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__Y__ctladj(%Array* %3, %Qubit* %4) - ret void -} - -define void @Lifted__PartialApplication__2__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %2 = load %Callable*, %Callable** %1 - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 2 - %4 = load %Qubit*, %Qubit** %3 - %5 = bitcast %Tuple* %arg-tuple to { %Tuple* }* - %6 = getelementptr inbounds { %Tuple* }, { %Tuple* }* %5, i32 0, i32 0 - %7 = load %Tuple*, %Tuple** %6 - %8 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %9 = bitcast %Tuple* %8 to { %Callable*, %Qubit*, %Tuple* }* - %10 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 0 - %11 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 1 - %12 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 2 - store %Callable* %2, %Callable** %10 - store %Qubit* %4, %Qubit** %11 - store %Tuple* %7, %Tuple** %12 - %13 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %14 = load %Callable*, %Callable** %13 - call void @__quantum__rt__callable_invoke(%Callable* %14, %Tuple* %8, %Tuple* %result-tuple) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %8, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__Z__body(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__Z__adj(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__Z__ctl(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__Z__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__Z__ctladj(%Array* %3, %Qubit* %4) - ret void -} - -define void @Lifted__PartialApplication__3__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %2 = load %Callable*, %Callable** %1 - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 2 - %4 = load %Qubit*, %Qubit** %3 - %5 = bitcast %Tuple* %arg-tuple to { %Tuple* }* - %6 = getelementptr inbounds { %Tuple* }, { %Tuple* }* %5, i32 0, i32 0 - %7 = load %Tuple*, %Tuple** %6 - %8 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %9 = bitcast %Tuple* %8 to { %Callable*, %Qubit*, %Tuple* }* - %10 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 0 - %11 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 1 - %12 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 2 - store %Callable* %2, %Callable** %10 - store %Qubit* %4, %Qubit** %11 - store %Tuple* %7, %Tuple** %12 - %13 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %14 = load %Callable*, %Callable** %13 - call void @__quantum__rt__callable_invoke(%Callable* %14, %Tuple* %8, %Tuple* %result-tuple) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %8, i64 -1) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__S__body(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__adj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Qubit* }* - %1 = getelementptr inbounds { %Qubit* }, { %Qubit* }* %0, i32 0, i32 0 - %2 = load %Qubit*, %Qubit** %1 - call void @Microsoft__Quantum__Intrinsic__S__adj(%Qubit* %2) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__S__ctl(%Array* %3, %Qubit* %4) - ret void -} - -define void @Microsoft__Quantum__Intrinsic__S__ctladj__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %arg-tuple to { %Array*, %Qubit* }* - %1 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 0 - %2 = getelementptr inbounds { %Array*, %Qubit* }, { %Array*, %Qubit* }* %0, i32 0, i32 1 - %3 = load %Array*, %Array** %1 - %4 = load %Qubit*, %Qubit** %2 - call void @Microsoft__Quantum__Intrinsic__S__ctladj(%Array* %3, %Qubit* %4) - ret void -} - -define void @Lifted__PartialApplication__4__body__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %2 = load %Callable*, %Callable** %1 - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 2 - %4 = load %Qubit*, %Qubit** %3 - %5 = bitcast %Tuple* %arg-tuple to { %Tuple* }* - %6 = getelementptr inbounds { %Tuple* }, { %Tuple* }* %5, i32 0, i32 0 - %7 = load %Tuple*, %Tuple** %6 - %8 = call %Tuple* @__quantum__rt__tuple_create(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3)) - %9 = bitcast %Tuple* %8 to { %Callable*, %Qubit*, %Tuple* }* - %10 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 0 - %11 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 1 - %12 = getelementptr inbounds { %Callable*, %Qubit*, %Tuple* }, { %Callable*, %Qubit*, %Tuple* }* %9, i32 0, i32 2 - store %Callable* %2, %Callable** %10 - store %Qubit* %4, %Qubit** %11 - store %Tuple* %7, %Tuple** %12 - %13 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %14 = load %Callable*, %Callable** %13 - call void @__quantum__rt__callable_invoke(%Callable* %14, %Tuple* %8, %Tuple* %result-tuple) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %8, i64 -1) - ret void -} - -define void @MemoryManagement__2__RefCount(%Tuple* %capture-tuple, i64 %count-change) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %2 = load %Callable*, %Callable** %1 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %2, i64 %count-change) - call void @__quantum__rt__callable_update_reference_count(%Callable* %2, i64 %count-change) - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %4 = load %Callable*, %Callable** %3 - call void @__quantum__rt__callable_memory_management(i32 0, %Callable* %4, i64 %count-change) - call void @__quantum__rt__callable_update_reference_count(%Callable* %4, i64 %count-change) - call void @__quantum__rt__tuple_update_reference_count(%Tuple* %capture-tuple, i64 %count-change) - ret void -} - -define void @MemoryManagement__2__AliasCount(%Tuple* %capture-tuple, i64 %count-change) { -entry: - %0 = bitcast %Tuple* %capture-tuple to { %Callable*, %Callable*, %Qubit* }* - %1 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 0 - %2 = load %Callable*, %Callable** %1 - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %2, i64 %count-change) - call void @__quantum__rt__callable_update_alias_count(%Callable* %2, i64 %count-change) - %3 = getelementptr inbounds { %Callable*, %Callable*, %Qubit* }, { %Callable*, %Callable*, %Qubit* }* %0, i32 0, i32 1 - %4 = load %Callable*, %Callable** %3 - call void @__quantum__rt__callable_memory_management(i32 1, %Callable* %4, i64 %count-change) - call void @__quantum__rt__callable_update_alias_count(%Callable* %4, i64 %count-change) - call void @__quantum__rt__tuple_update_alias_count(%Tuple* %capture-tuple, i64 %count-change) - ret void -} - -declare void @__quantum__rt__callable_update_reference_count(%Callable*, i64) - -define { %String* }* @Microsoft__Quantum__Targeting__TargetInstruction__body(%String* %__Item1__) { -entry: - %0 = call %Tuple* @__quantum__rt__tuple_create(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64)) - %1 = bitcast %Tuple* %0 to { %String* }* - %2 = getelementptr inbounds { %String* }, { %String* }* %1, i32 0, i32 0 - store %String* %__Item1__, %String** %2 - call void @__quantum__rt__string_update_reference_count(%String* %__Item1__, i64 1) - ret { %String* }* %1 -} - -declare void @__quantum__rt__string_update_reference_count(%String*, i64) - -declare void @__quantum__rt__tuple_update_alias_count(%Tuple*, i64) diff --git a/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj b/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj index dbcade9d0a4..c85fc9bce0b 100644 --- a/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj +++ b/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj @@ -22,7 +22,7 @@ - + diff --git a/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj b/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj index b9a9f23a05e..e4ddd55cd52 100644 --- a/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj +++ b/src/Simulation/QCTraceSimulator.Tests/Tests.Microsoft.Quantum.Simulation.QCTraceSimulatorRuntime.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj b/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj index 55f5296116c..a60a126486d 100644 --- a/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj +++ b/src/Simulation/QSharpCore/Microsoft.Quantum.QSharp.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj b/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj index 5f2739dc51b..90085eb17cd 100644 --- a/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj +++ b/src/Simulation/QSharpFoundation/Microsoft.Quantum.QSharp.Foundation.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj index 8d6648d99bd..2298e68b6de 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/HoneywellExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj b/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj index 5df0333fbfd..831091933c3 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/IntrinsicTests/IntrinsicTests.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.1 diff --git a/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj index 155c413dd90..e25ff063324 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/IonQExe/IonQExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj index 967fdc57f93..1efd1964b47 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library with Spaces/Library with Spaces.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 false diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj index 3be0a69493f..45a59010ce2 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library1/Library1.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 diff --git a/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj b/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj index 3be0a69493f..45a59010ce2 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/Library2/Library2.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 diff --git a/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj index 10e31d76d29..f364193203a 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/QCIExe/QCIExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj index 46fffc1465e..882c9fff161 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/QSharpExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj b/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj index efc6191b015..84a15bd4b68 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/TargetedExe.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj index 6e8e0d10e34..9361b91575d 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj +++ b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/UnitTests.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.1 diff --git a/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj b/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj index 281a717746a..5b2ca44efa6 100644 --- a/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj +++ b/src/Simulation/Simulators.Tests/Tests.Microsoft.Quantum.Simulators.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj b/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj index 48eae1fd4aa..f64f0332e09 100644 --- a/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj +++ b/src/Simulation/Simulators.Type1.Tests/Tests.Microsoft.Quantum.Simulators.Type1.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj b/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj index 4ecc2f5d180..11d8255db01 100644 --- a/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj +++ b/src/Simulation/Simulators.Type2.Tests/Tests.Microsoft.Quantum.Simulators.Type2.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators.Type3.Tests/Tests.Microsoft.Quantum.Simulators.Type3.csproj b/src/Simulation/Simulators.Type3.Tests/Tests.Microsoft.Quantum.Simulators.Type3.csproj index 4de9084ec8b..6c104250bfb 100644 --- a/src/Simulation/Simulators.Type3.Tests/Tests.Microsoft.Quantum.Simulators.Type3.csproj +++ b/src/Simulation/Simulators.Type3.Tests/Tests.Microsoft.Quantum.Simulators.Type3.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj index 2704eb6a47c..07b0313ed5c 100644 --- a/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj +++ b/src/Simulation/Simulators/Microsoft.Quantum.Simulators.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj b/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj index f75c9ba8145..7df28e51b76 100644 --- a/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj +++ b/src/Simulation/Type1Core/Microsoft.Quantum.Type1.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj b/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj index 804ad9d7054..524b9c41c1e 100644 --- a/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj +++ b/src/Simulation/Type2Core/Microsoft.Quantum.Type2.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.csproj b/src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.csproj index bfd3eee533e..8ad18d2562c 100644 --- a/src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.csproj +++ b/src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.csproj @@ -1,4 +1,4 @@ - + From c172e6fe9fd5d2050a5e0774412966978609ca6d Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Fri, 19 Mar 2021 11:49:25 -0700 Subject: [PATCH 05/32] Fix dynamic assembly load logic in Tracer (#570) This fixes an issue where the fallback logic in the `QCTraceSimulator` for dynamically loading the QSharp.Core target package wouldn't work for manually written C# drivers. This fixes the issue by introducing new fallback logic that relies on the assembly name of the current simulator assembly to determine the full name of the QSharp.Core assembly to load. Fixes #540 Fixes #542 --- src/Simulation/EntryPointDriver/Simulation.cs | 6 +- .../QCTraceSimulator/QCTraceSimulatorImpl.cs | 58 ++++++++++--------- .../ResourcesEstimator/ResourcesEstimator.cs | 2 +- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/src/Simulation/EntryPointDriver/Simulation.cs b/src/Simulation/EntryPointDriver/Simulation.cs index 4e942364fe4..dfa3a9a72f5 100644 --- a/src/Simulation/EntryPointDriver/Simulation.cs +++ b/src/Simulation/EntryPointDriver/Simulation.cs @@ -38,8 +38,10 @@ internal static async Task Simulate( var coreAssemblyName = (from aName in entryPoint.GetType().Assembly.GetReferencedAssemblies() where aName.Name == "Microsoft.Quantum.QSharp.Core" - select aName).First(); - var coreAssembly = Assembly.Load(coreAssemblyName.FullName); + select aName).FirstOrDefault(); + var coreAssembly = coreAssemblyName != null ? + Assembly.Load(coreAssemblyName.FullName) : + null; var resourcesEstimator = new ResourcesEstimator(coreAssembly); await resourcesEstimator.Run(entryPoint.CreateArgument(parseResult)); diff --git a/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulatorImpl.cs b/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulatorImpl.cs index 5d37224316e..630dced7b4e 100644 --- a/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulatorImpl.cs +++ b/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulatorImpl.cs @@ -152,41 +152,43 @@ private void RegisterPrimitiveOperationsGivenAsCircuits(Assembly? coreAssembly) var intrinsicAssembly = coreAssembly; if (intrinsicAssembly == null) { - intrinsicAssembly = - (from assembly in AppDomain.CurrentDomain.GetAssemblies() - where assembly.GetType("Microsoft.Quantum.Intrinsic.X") != null - select assembly).First(); + var currentName = this.GetType().Assembly.GetName(); + var coreName = currentName.FullName.Replace("Simulators", "QSharp.Core"); + try + { + intrinsicAssembly = AppDomain.CurrentDomain.Load(coreName); + } + catch { } } - IEnumerable primitiveOperationTypes = - from op in intrinsicAssembly.GetExportedTypes() - where op.IsSubclassOf(typeof(AbstractCallable)) - select op; - if (primitiveOperationTypes.Count() == 0) + if (intrinsicAssembly != null) { - throw new Exception("Unable to load intrinsic types. The ResourcesEstimator can only be used with the default execution target."); - } - - IEnumerable primitiveOperationAsCircuits = - from op in typeof(Circuits.X).Assembly.GetExportedTypes() - where op.IsSubclassOf(typeof(AbstractCallable)) - && op.Namespace == typeof(Circuits.X).Namespace - select op; + IEnumerable primitiveOperationTypes = + from op in intrinsicAssembly.GetExportedTypes() + where op.IsSubclassOf(typeof(AbstractCallable)) + select op; - foreach (Type operationType in primitiveOperationTypes) - { - IEnumerable machingCircuitTypes = - from op in primitiveOperationAsCircuits - where op.Name == operationType.Name + IEnumerable primitiveOperationAsCircuits = + from op in typeof(Circuits.X).Assembly.GetExportedTypes() + where op.IsSubclassOf(typeof(AbstractCallable)) + && op.Namespace == typeof(Circuits.X).Namespace select op; - int numberOfMatchesFound = machingCircuitTypes.Count(); - Debug.Assert( - numberOfMatchesFound <= 1, - "There should be at most one matching operation."); - if (numberOfMatchesFound == 1) + foreach (Type operationType in primitiveOperationTypes) { - Register(operationType, machingCircuitTypes.First(), operationType.ICallableType()); + IEnumerable machingCircuitTypes = + from op in primitiveOperationAsCircuits + where op.Name == operationType.Name + select op; + + int numberOfMatchesFound = machingCircuitTypes.Count(); + Debug.Assert( + numberOfMatchesFound <= 1, + "There should be at most one matching operation."); + if (numberOfMatchesFound == 1) + { + Register(operationType, machingCircuitTypes.First(), operationType.ICallableType()); + } } } } diff --git a/src/Simulation/Simulators/ResourcesEstimator/ResourcesEstimator.cs b/src/Simulation/Simulators/ResourcesEstimator/ResourcesEstimator.cs index a821fd37663..253c14cb2f0 100644 --- a/src/Simulation/Simulators/ResourcesEstimator/ResourcesEstimator.cs +++ b/src/Simulation/Simulators/ResourcesEstimator/ResourcesEstimator.cs @@ -48,7 +48,7 @@ public static QCTraceSimulatorConfiguration RecommendedConfig() => /// Constructor used by entry point driver to provide the assembly for core types that /// need to be overriden. /// - public ResourcesEstimator(Assembly coreAssembly) : base(RecommendedConfig(), coreAssembly) + public ResourcesEstimator(Assembly? coreAssembly) : base(RecommendedConfig(), coreAssembly) { } From 175a4ed1e7e9f86104720465c92f09fdee2577ed Mon Sep 17 00:00:00 2001 From: Robin Kuzmin Date: Sat, 20 Mar 2021 19:23:43 -0700 Subject: [PATCH 06/32] Updated .gitignore (#574) --- src/QirRuntime/.gitignore | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/QirRuntime/.gitignore diff --git a/src/QirRuntime/.gitignore b/src/QirRuntime/.gitignore new file mode 100644 index 00000000000..b01c4cb32d9 --- /dev/null +++ b/src/QirRuntime/.gitignore @@ -0,0 +1,10 @@ +# These auto-generated files bother when switching between the branches. +samples/StandaloneInputReference/qir-standalone-input-reference.ll +samples/StandaloneInputReference/qsharp/qir/ +test/FullstateSimulator/qir-test-simulator.ll +test/FullstateSimulator/qsharp/qir/ +test/QIR-dynamic/qir-test-random.ll +test/QIR-dynamic/qsharp/qir/ +test/QIR-tracer/qsharp/qir/ +test/QIR-tracer/tracer-qir.ll + From d937524b119b01172f69ccfdb01252aec1f6f085 Mon Sep 17 00:00:00 2001 From: Robin Kuzmin Date: Sun, 21 Mar 2021 12:02:41 -0700 Subject: [PATCH 07/32] Removed __quantum__rt__callable_memory_management() (#575) --- src/QirRuntime/lib/QIR/bridge-rt.ll | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/QirRuntime/lib/QIR/bridge-rt.ll b/src/QirRuntime/lib/QIR/bridge-rt.ll index 950a26abf67..ebb41b97528 100644 --- a/src/QirRuntime/lib/QIR/bridge-rt.ll +++ b/src/QirRuntime/lib/QIR/bridge-rt.ll @@ -386,20 +386,6 @@ define dllexport %Callable* @__quantum__rt__callable_make_controlled(%Callable* ret %Callable* %.clb_cnt } -; After both the compiler and runtime are in sync with https://github.com/microsoft/qsharp-language/pull/83: -; Regenerate the following .ll files with the updated compiler such that they don't call this function any more: -; test\FullstateSimulator\qir-test-simulator.ll -; test\QIR-tracer\tracer-qir-lnx.ll -; test\QIR-tracer\tracer-qir-win.ll -; Remove this function. -; Resolve https://github.com/microsoft/qsharp-runtime/issues/568 (Remove `__quantum__rt__callable_memory_management()`) -define dllexport void @__quantum__rt__callable_memory_management(i32 %index, %Callable* %.clb, i64 %.parameter) { - %clb = bitcast %Callable* %.clb to %"struct.QirCallable"* - %parameter = trunc i64 %.parameter to i32 - call void @quantum__rt__callable_memory_management(i32 %index, %"struct.QirCallable"* %clb, i32 %parameter) - ret void -} - define dllexport void @__quantum__rt__capture_update_reference_count(%Callable* %.clb, i32 %count) { %clb = bitcast %Callable* %.clb to %"struct.QirCallable"* call void @quantum__rt__callable_memory_management(i32 0, %"struct.QirCallable"* %clb, i32 %count) From a9245fb759c6a415fd8daaca733ba78a0e9d9f4f Mon Sep 17 00:00:00 2001 From: "Stefan J. Wernli" Date: Mon, 22 Mar 2021 11:28:32 -0700 Subject: [PATCH 08/32] Fix for dynamic type load when inheritance used (#576) If inheritance is used, the `this` in QCTraceSimulatorImpl wont resolve to the right assembly. This uses the QCTraceSimulatorImpl type itself so that the assembly matching the QDK can be resolved. --- .../Simulators/QCTraceSimulator/QCTraceSimulatorImpl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulatorImpl.cs b/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulatorImpl.cs index 630dced7b4e..78a52f30ada 100644 --- a/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulatorImpl.cs +++ b/src/Simulation/Simulators/QCTraceSimulator/QCTraceSimulatorImpl.cs @@ -152,7 +152,7 @@ private void RegisterPrimitiveOperationsGivenAsCircuits(Assembly? coreAssembly) var intrinsicAssembly = coreAssembly; if (intrinsicAssembly == null) { - var currentName = this.GetType().Assembly.GetName(); + var currentName = typeof(QCTraceSimulatorImpl).Assembly.GetName(); var coreName = currentName.FullName.Replace("Simulators", "QSharp.Core"); try { From dce24563c94ab807092c8bcf59f2e80aac7c544b Mon Sep 17 00:00:00 2001 From: Robin Kuzmin Date: Tue, 23 Mar 2021 10:13:44 -0700 Subject: [PATCH 09/32] Added __quantum__rt__message (#579) * Turned off the test for Message() * Moved lib/QSharpFoundation/intrinsicsOut.cpp -> lib/QIR/rtOut.cpp. * Moved SetOutputStream() * Build fix. * Uncommented the test * Clean-up. * CR changes --- src/QirRuntime/lib/QIR/CMakeLists.txt | 1 + src/QirRuntime/lib/QIR/bridge-rt.ll | 15 +++++++++++++-- .../intrinsicsOut.cpp => QIR/rtOut.cpp} | 5 ++--- src/QirRuntime/lib/QIR/utils.cpp | 6 ------ .../lib/QSharpFoundation/CMakeLists.txt | 1 - .../lib/QSharpFoundation/qsharp-foundation-qis.ll | 5 +++-- .../QSharpFoundation/qsharp__foundation__qis.hpp | 2 -- src/QirRuntime/public/QirRuntime.hpp | 12 +++++++++++- src/QirRuntime/public/SimFactory.hpp | 1 - src/QirRuntime/test/QIR-static/qir-test-ouput.cpp | 3 +-- 10 files changed, 31 insertions(+), 20 deletions(-) rename src/QirRuntime/lib/{QSharpFoundation/intrinsicsOut.cpp => QIR/rtOut.cpp} (86%) diff --git a/src/QirRuntime/lib/QIR/CMakeLists.txt b/src/QirRuntime/lib/QIR/CMakeLists.txt index 8f1d7226ee1..a9afbe799ef 100644 --- a/src/QirRuntime/lib/QIR/CMakeLists.txt +++ b/src/QirRuntime/lib/QIR/CMakeLists.txt @@ -22,6 +22,7 @@ set(rt_sup_source_files delegated.cpp strings.cpp utils.cpp + rtOut.cpp ) add_library(qir-rt-support ${rt_sup_source_files}) diff --git a/src/QirRuntime/lib/QIR/bridge-rt.ll b/src/QirRuntime/lib/QIR/bridge-rt.ll index ebb41b97528..71498842c92 100644 --- a/src/QirRuntime/lib/QIR/bridge-rt.ll +++ b/src/QirRuntime/lib/QIR/bridge-rt.ll @@ -108,6 +108,10 @@ declare i8* @quantum__rt_string_get_data(%"struct.QirString"* %str) declare i32 @quantum__rt_string_get_length(%"struct.QirString"* %str) +;------------------------------------------------------------------------------ +; message +; +declare void @quantum__rt__message(%"struct.QirString"* %str) ;======================================================================================================================= ; __quantum__rt__* bridge implementation @@ -138,6 +142,12 @@ define dllexport void @__quantum__rt__fail(%String* %.str) { ret void } +define dllexport void @__quantum__rt__message(%String* %.str) { + %str = bitcast %String* %.str to %"struct.QirString"* + call void @quantum__rt__message(%"struct.QirString"* %str) + ret void +} + ;------------------------------------------------------------------------------ ; qubits bridge @@ -480,19 +490,20 @@ define dllexport %String* @__quantum__rt__range_to_string(%Range %.range) { ret %String* %.str } -define i8* @__quantum__rt_string_get_data(%String* %.str) { +define dllexport i8* @__quantum__rt_string_get_data(%String* %.str) { %str = bitcast %String* %.str to %"struct.QirString"* %result = call i8* @quantum__rt_string_get_data(%"struct.QirString"* %str) ret i8* %result } -define i32 @__quantum__rt_string_get_length(%String* %.str) { +define dllexport i32 @__quantum__rt_string_get_length(%String* %.str) { %str = bitcast %String* %.str to %"struct.QirString"* %result = call i32 @quantum__rt_string_get_length(%"struct.QirString"* %str) ret i32 %result } + ;------------------------------------------------------------------------------ ; bigints bridge ; diff --git a/src/QirRuntime/lib/QSharpFoundation/intrinsicsOut.cpp b/src/QirRuntime/lib/QIR/rtOut.cpp similarity index 86% rename from src/QirRuntime/lib/QSharpFoundation/intrinsicsOut.cpp rename to src/QirRuntime/lib/QIR/rtOut.cpp index 99eb2292dac..5f921c706fc 100644 --- a/src/QirRuntime/lib/QSharpFoundation/intrinsicsOut.cpp +++ b/src/QirRuntime/lib/QIR/rtOut.cpp @@ -4,8 +4,7 @@ #include #include "QirTypes.hpp" -#include "SimFactory.hpp" -#include "qsharp__foundation__qis.hpp" +#include "QirRuntime.hpp" // Forward declarations: static std::ostream& GetOutputStream(); @@ -13,7 +12,7 @@ static std::ostream& GetOutputStream(); // Public API: extern "C" { - void quantum__qis__message__body(QirString* qstr) // NOLINT + void quantum__rt__message(QirString* qstr) // NOLINT { GetOutputStream() << qstr->str << std::endl; } diff --git a/src/QirRuntime/lib/QIR/utils.cpp b/src/QirRuntime/lib/QIR/utils.cpp index 00bd1959ed5..16ab94fa645 100644 --- a/src/QirRuntime/lib/QIR/utils.cpp +++ b/src/QirRuntime/lib/QIR/utils.cpp @@ -59,10 +59,4 @@ extern "C" throw std::runtime_error(str); } - // Include the given message in the computation's execution log or equivalent. - // TODO: should we allow the user to register their own output? - void quantum__rt__message(QirString* msg) // NOLINT - { - std::cout << msg->str; - } } \ No newline at end of file diff --git a/src/QirRuntime/lib/QSharpFoundation/CMakeLists.txt b/src/QirRuntime/lib/QSharpFoundation/CMakeLists.txt index 6318dc7f062..216b971b9d8 100644 --- a/src/QirRuntime/lib/QSharpFoundation/CMakeLists.txt +++ b/src/QirRuntime/lib/QSharpFoundation/CMakeLists.txt @@ -13,7 +13,6 @@ compile_from_qir(qsharp-foundation-qis ${qsharp_foundation_qis_target}) # set(qsharp_foundation_sup_source_files intrinsicsMath.cpp - intrinsicsOut.cpp conditionals.cpp ) diff --git a/src/QirRuntime/lib/QSharpFoundation/qsharp-foundation-qis.ll b/src/QirRuntime/lib/QSharpFoundation/qsharp-foundation-qis.ll index 4bc362335c1..71b45b7c692 100644 --- a/src/QirRuntime/lib/QSharpFoundation/qsharp-foundation-qis.ll +++ b/src/QirRuntime/lib/QSharpFoundation/qsharp-foundation-qis.ll @@ -31,13 +31,14 @@ %struct.QirString = type opaque %PauliId = type i32 -declare void @quantum__qis__message__body(%struct.QirString* %str) +declare dllimport void @quantum__rt__message(%"struct.QirString"* %str) ;=============================================================================== ; +; To do: remove this function after the https://github.com/microsoft/qsharp-runtime/issues/578 is resolved. define dllexport void @__quantum__qis__message__body(%String* %.str) { %str = bitcast %String* %.str to %struct.QirString* - call void @quantum__qis__message__body(%struct.QirString* %str) + call void @quantum__rt__message(%"struct.QirString"* %str) ret void } diff --git a/src/QirRuntime/lib/QSharpFoundation/qsharp__foundation__qis.hpp b/src/QirRuntime/lib/QSharpFoundation/qsharp__foundation__qis.hpp index 3c15948463b..5e64f5f0751 100644 --- a/src/QirRuntime/lib/QSharpFoundation/qsharp__foundation__qis.hpp +++ b/src/QirRuntime/lib/QSharpFoundation/qsharp__foundation__qis.hpp @@ -27,8 +27,6 @@ namespace Quantum */ extern "C" { - QIR_SHARED_API void quantum__qis__message__body(QirString* qstr); // NOLINT - // Q# Math: QIR_SHARED_API bool quantum__qis__isnan__body(double d); // NOLINT QIR_SHARED_API double quantum__qis__infinity__body(); // NOLINT diff --git a/src/QirRuntime/public/QirRuntime.hpp b/src/QirRuntime/public/QirRuntime.hpp index 563af6a2d50..f7f393eaaa0 100644 --- a/src/QirRuntime/public/QirRuntime.hpp +++ b/src/QirRuntime/public/QirRuntime.hpp @@ -5,6 +5,7 @@ #include #include // for va_list +#include #include "CoreTypes.hpp" #include "QirTypes.hpp" @@ -302,4 +303,13 @@ extern "C" // Returns true if the first big integer is greater than or equal to the second, false otherwise. // TODO QIR_SHARED_API bool quantum__rt__bigint_greater_eq(QirBigInt*, QirBigInt*); // NOLINT -} \ No newline at end of file +} + +// To do: consider extracting to QirRuntimeOut.hpp +namespace Microsoft // Replace with `namespace Microsoft::Quantum` after migration to C++17. +{ +namespace Quantum +{ + QIR_SHARED_API std::ostream& SetOutputStream(std::ostream & newOStream); +} // namespace Microsoft +} // namespace Quantum diff --git a/src/QirRuntime/public/SimFactory.hpp b/src/QirRuntime/public/SimFactory.hpp index f8ab837443e..14128657262 100644 --- a/src/QirRuntime/public/SimFactory.hpp +++ b/src/QirRuntime/public/SimFactory.hpp @@ -18,6 +18,5 @@ namespace Quantum // Full State Simulator QIR_SHARED_API std::unique_ptr CreateFullstateSimulator(); - QIR_SHARED_API std::ostream& SetOutputStream(std::ostream& newOStream); } // namespace Quantum } // namespace Microsoft \ No newline at end of file diff --git a/src/QirRuntime/test/QIR-static/qir-test-ouput.cpp b/src/QirRuntime/test/QIR-static/qir-test-ouput.cpp index a7d47893926..9331edc0a0f 100644 --- a/src/QirRuntime/test/QIR-static/qir-test-ouput.cpp +++ b/src/QirRuntime/test/QIR-static/qir-test-ouput.cpp @@ -6,8 +6,7 @@ #include "catch.hpp" #include "QirTypes.hpp" -#include "SimFactory.hpp" -#include "qsharp__foundation_internal.hpp" +#include "QirRuntime.hpp" extern "C" void Microsoft__Quantum__Testing__QIR__Out__MessageTest__body(void*); // NOLINT From 9d4159d6f3a81f0d8b200143805281cf0e3011f0 Mon Sep 17 00:00:00 2001 From: Scott Carda <55811729+ScottCarda-MS@users.noreply.github.com> Date: Tue, 23 Mar 2021 16:58:45 -0700 Subject: [PATCH 10/32] Multiple Entry Points For Entry Point Driver (#528) Added Multiple Entry points for the Entry Point Driver --- Simulation.sln | 4 +- .../qir-standalone-input-reference.csproj | 2 +- .../qsharp/qir-test-simulator.csproj | 2 +- .../QIR-dynamic/qsharp/qir-test-random.csproj | 2 +- .../test/QIR-static/qsharp/qir-gen.csproj | 2 +- .../test/QIR-tracer/qsharp/tracer-qir.csproj | 2 +- src/Simulation/CSharpGeneration/EntryPoint.fs | 206 +++++-- .../Microsoft.Quantum.CSharpGeneration.fsproj | 4 +- .../CSharpGeneration/RewriteStep.fs | 47 +- src/Simulation/Common/Simulators.Dev.props | 2 +- .../EntryPointDriver.Tests/Tests.fs | 117 +++- .../EntryPointDriver.Tests/Tests.qs | 46 ++ src/Simulation/EntryPointDriver/Azure.cs | 44 +- src/Simulation/EntryPointDriver/Driver.cs | 551 +++++++++++------- .../EntryPointDriver/DriverSettings.cs | 34 +- .../EntryPointDriver/IEntryPoint.cs | 46 +- src/Simulation/EntryPointDriver/Simulation.cs | 28 +- ....Simulation.QCTraceSimulatorRuntime.csproj | 2 +- .../Microsoft.Quantum.QSharp.Core.csproj | 2 +- ...Microsoft.Quantum.QSharp.Foundation.csproj | 4 +- .../HoneywellExe/HoneywellExe.csproj | 4 +- .../IntrinsicTests/IntrinsicTests.csproj | 4 +- .../TestProjects/IonQExe/IonQExe.csproj | 4 +- .../Library with Spaces.csproj | 4 +- .../TestProjects/Library1/Library1.csproj | 4 +- .../TestProjects/Library2/Library2.csproj | 4 +- .../TestProjects/QCIExe/QCIExe.csproj | 4 +- .../TestProjects/QSharpExe/QSharpExe.csproj | 4 +- .../TargetedExe/TargetedExe.csproj | 4 +- .../TestProjects/UnitTests/UnitTests.csproj | 4 +- .../Tests.Microsoft.Quantum.Simulators.csproj | 2 +- ....Microsoft.Quantum.Simulators.Type1.csproj | 2 +- ....Microsoft.Quantum.Simulators.Type2.csproj | 2 +- ....Microsoft.Quantum.Simulators.Type3.csproj | 2 +- .../Microsoft.Quantum.Simulators.csproj | 2 +- .../Microsoft.Quantum.Type1.Core.csproj | 2 +- .../Microsoft.Quantum.Type2.Core.csproj | 2 +- .../Microsoft.Quantum.Type3.Core.csproj | 2 +- 38 files changed, 782 insertions(+), 421 deletions(-) diff --git a/Simulation.sln b/Simulation.sln index dc9f314bfcf..352761e1cfa 100644 --- a/Simulation.sln +++ b/Simulation.sln @@ -63,7 +63,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IonQExe", "src\Simulation\S EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QCIExe", "src\Simulation\Simulators.Tests\TestProjects\QCIExe\QCIExe.csproj", "{C015FF41-9A51-4AF0-AEFC-2547D596B10A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TargetedExe", "src\Simulation\Simulators.Tests\TestProjects\TargetedExe\TargetedExe.csproj", "{D292BF18-3956-4827-820E-254C3F81EF09}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TargetedExe", "src\Simulation\Simulators.Tests\TestProjects\TargetedExe\TargetedExe.csproj", "{D292BF18-3956-4827-820E-254C3F81EF09}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.QSharp.Foundation", "src\Simulation\QSharpFoundation\Microsoft.Quantum.QSharp.Foundation.csproj", "{DB45AD73-4D91-43F3-85CC-C63614A96FB0}" EndProject @@ -71,7 +71,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Quantum.Type2.Cor EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Microsoft.Quantum.Simulators.Type2", "src\Simulation\Simulators.Type2.Tests\Tests.Microsoft.Quantum.Simulators.Type2.csproj", "{ED3D7040-4B3F-4217-A75E-9DF63DD84707}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntrinsicTests", "src\Simulation\Simulators.Tests\TestProjects\IntrinsicTests\IntrinsicTests.csproj", "{4EF958CA-B4A6-4E5F-924A-100B5615BEC3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntrinsicTests", "src\Simulation\Simulators.Tests\TestProjects\IntrinsicTests\IntrinsicTests.csproj", "{4EF958CA-B4A6-4E5F-924A-100B5615BEC3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests.Microsoft.Quantum.Simulators.Type1", "src\Simulation\Simulators.Type1.Tests\Tests.Microsoft.Quantum.Simulators.Type1.csproj", "{EB6E3DBD-C884-4241-9BC4-8281191D1F53}" EndProject diff --git a/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj b/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj index 74ef21518f7..f5390123881 100644 --- a/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj +++ b/src/QirRuntime/samples/StandaloneInputReference/qsharp/qir-standalone-input-reference.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/QirRuntime/test/FullstateSimulator/qsharp/qir-test-simulator.csproj b/src/QirRuntime/test/FullstateSimulator/qsharp/qir-test-simulator.csproj index 5166db5e375..47093e07fa3 100644 --- a/src/QirRuntime/test/FullstateSimulator/qsharp/qir-test-simulator.csproj +++ b/src/QirRuntime/test/FullstateSimulator/qsharp/qir-test-simulator.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/QirRuntime/test/QIR-dynamic/qsharp/qir-test-random.csproj b/src/QirRuntime/test/QIR-dynamic/qsharp/qir-test-random.csproj index 5166db5e375..47093e07fa3 100644 --- a/src/QirRuntime/test/QIR-dynamic/qsharp/qir-test-random.csproj +++ b/src/QirRuntime/test/QIR-dynamic/qsharp/qir-test-random.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj b/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj index b061ce01e44..ee5e2265946 100644 --- a/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj +++ b/src/QirRuntime/test/QIR-static/qsharp/qir-gen.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/QirRuntime/test/QIR-tracer/qsharp/tracer-qir.csproj b/src/QirRuntime/test/QIR-tracer/qsharp/tracer-qir.csproj index 0167e216edf..eb525775779 100644 --- a/src/QirRuntime/test/QIR-tracer/qsharp/tracer-qir.csproj +++ b/src/QirRuntime/test/QIR-tracer/qsharp/tracer-qir.csproj @@ -1,4 +1,4 @@ - + Exe diff --git a/src/Simulation/CSharpGeneration/EntryPoint.fs b/src/Simulation/CSharpGeneration/EntryPoint.fs index 4bd9317a3c9..03349ea29e8 100644 --- a/src/Simulation/CSharpGeneration/EntryPoint.fs +++ b/src/Simulation/CSharpGeneration/EntryPoint.fs @@ -26,24 +26,6 @@ let entryPointClassName = "__QsEntryPoint__" /// The namespace containing the non-generated parts of the entry point driver. let private driverNamespace = "Microsoft.Quantum.EntryPointDriver" -/// The driver settings object. -let private driverSettings = - let newDriverSettings = driverNamespace + ".DriverSettings" |> ``type`` |> SyntaxFactory.ObjectCreationExpression - let namedArg (name : string) expr = SyntaxFactory.NameColon name |> (SyntaxFactory.Argument expr).WithNameColon - let immutableList elements = invoke (ident "System.Collections.Immutable.ImmutableList.Create") ``(`` elements ``)`` - let simulatorOptionAliases = - [ literal <| "--" + fst CommandLineArguments.SimulatorOption - literal <| "-" + snd CommandLineArguments.SimulatorOption ] - |> immutableList - [ namedArg "simulatorOptionAliases" simulatorOptionAliases - namedArg "quantumSimulatorName" <| literal AssemblyConstants.QuantumSimulator - namedArg "toffoliSimulatorName" <| literal AssemblyConstants.ToffoliSimulator - namedArg "resourcesEstimatorName" <| literal AssemblyConstants.ResourcesEstimator ] - |> SyntaxFactory.SeparatedList - |> SyntaxFactory.ArgumentList - |> newDriverSettings.WithArgumentList - :> ExpressionSyntax - /// A sequence of all of the named parameters in the argument tuple and their respective C# and Q# types. let rec private parameters context doc = function | QsTupleItem variable -> @@ -75,7 +57,7 @@ let private parameterOptionsProperty parameters = ``property-arrow_get`` optionsEnumerableTypeName "Options" [``public``] get (``=>`` (``new array`` (Some optionTypeName) options)) -/// A method that creates an instance of the default simulator if it is a custom simulator. +/// A lambda that creates an instance of the default simulator if it is a custom simulator. let private customSimulatorFactory name = let isCustomSimulator = not <| List.contains name [ @@ -87,11 +69,7 @@ let private customSimulatorFactory name = if isCustomSimulator then ``new`` (``type`` name) ``(`` [] ``)`` else upcast SyntaxFactory.ThrowExpression (``new`` (``type`` "InvalidOperationException") ``(`` [] ``)``) - - arrow_method "IOperationFactory" "CreateDefaultCustomSimulator" ``<<`` [] ``>>`` - ``(`` [] ``)`` - [``public``] - (Some (``=>`` factory)) + ``() =>`` [] factory :> ExpressionSyntax /// A method that creates the argument tuple for the entry point, given the command-line parsing result. let private createArgument context entryPoint = @@ -119,65 +97,169 @@ let private callableTypeNames context (callable : QsCallable) = let returnTypeName = SimulationCode.roslynTypeName context callable.Signature.ReturnType callableName, argTypeName, returnTypeName -/// The main method for the standalone executable. -let private mainMethod context entryPoint = +/// Generates the class name for an entry point class. +let private entryPointClassFullName (entryPoint : QsCallable) = + { Namespace = entryPoint.FullName.Namespace; Name = entryPointClassName + entryPoint.FullName.Name } + +/// Generates the Submit method for an entry point class. +let private submitMethod context entryPoint = + let callableName, _, _ = callableTypeNames context entryPoint + let parseResultParamName = "parseResult" + let settingsParamName = "settings" + let args = + [ + ident callableName <|.|> ident "Info" + ident "this" <.> (ident "CreateArgument", [ident parseResultParamName]) + ident settingsParamName :> ExpressionSyntax + ] + arrow_method "System.Threading.Tasks.Task" "Submit" ``<<`` [] ``>>`` + ``(`` + [ + param parseResultParamName ``of`` (``type`` "System.CommandLine.Parsing.ParseResult") + param settingsParamName ``of`` (``type`` (driverNamespace + ".AzureSettings")) + ] + ``)`` + [``public``] + (Some (``=>`` (ident (driverNamespace + ".Azure") <.> (ident "Submit", args)))) + +/// Generates the Simulate method for an entry point class. +let private simulateMethod context entryPoint = let callableName, argTypeName, returnTypeName = callableTypeNames context entryPoint - let driverType = generic (driverNamespace + ".Driver") ``<<`` [callableName; argTypeName; returnTypeName] ``>>`` - let entryPointInstance = ``new`` (``type`` entryPointClassName) ``(`` [] ``)`` - let driver = ``new`` driverType ``(`` [driverSettings; entryPointInstance] ``)`` - let commandLineArgsName = "args" - arrow_method "System.Threading.Tasks.Task" "Main" ``<<`` [] ``>>`` - ``(`` [param commandLineArgsName ``of`` (``type`` "string[]")] ``)`` - [``private``; ``static``; async] - (Some (``=>`` (await (driver <.> (ident "Run", [ident commandLineArgsName]))))) + let simulationType = generic (driverNamespace + ".Simulation") ``<<`` [callableName; argTypeName; returnTypeName] ``>>`` + let parseResultParamName = "parseResult" + let settingsParamName = "settings" + let simulatorParamName = "simulator" + let args = + [ + ident "this" :> ExpressionSyntax + ident "this" <.> (ident "CreateArgument", [ident parseResultParamName]) + ident settingsParamName :> ExpressionSyntax + ident simulatorParamName :> ExpressionSyntax + ] + arrow_method "System.Threading.Tasks.Task" "Simulate" ``<<`` [] ``>>`` + ``(`` + [ + param parseResultParamName ``of`` (``type`` "System.CommandLine.Parsing.ParseResult") + param settingsParamName ``of`` (``type`` (driverNamespace + ".DriverSettings")) + param simulatorParamName ``of`` (``type`` "string") + ] + ``)`` + [``public``] + (Some (``=>`` (simulationType <.> (ident "Simulate", args)))) /// The class that adapts the entry point for use with the command-line parsing library and the driver. -let private entryPointClass context entryPoint = - let callableName, argTypeName, returnTypeName = callableTypeNames context entryPoint +let private entryPointClass context (entryPoint : QsCallable) = let property name typeName value = ``property-arrow_get`` typeName name [``public``] get (``=>`` value) + let nameProperty = + entryPoint.FullName.ToString() + |> literal + |> property "Name" "string" let summaryProperty = (PrintSummary entryPoint.Documentation false).Trim () |> literal |> property "Summary" "string" let parameters = parameters context entryPoint.Documentation entryPoint.ArgumentTuple - let defaultSimulator = - context.assemblyConstants.TryGetValue AssemblyConstants.DefaultSimulator - |> fun (_, value) -> if String.IsNullOrWhiteSpace value then AssemblyConstants.QuantumSimulator else value - let defaultSimulatorNameProperty = literal defaultSimulator |> property "DefaultSimulatorName" "string" - let defaultExecutionTargetProperty = - context.assemblyConstants.TryGetValue AssemblyConstants.ExecutionTarget - |> (fun (_, value) -> if value = null then "" else value) - |> literal - |> property "DefaultExecutionTarget" "string" - let infoProperty = - property "Info" (sprintf "EntryPointInfo<%s, %s>" argTypeName returnTypeName) - (ident callableName <|.|> ident "Info") let members : MemberDeclarationSyntax list = [ + nameProperty summaryProperty parameterOptionsProperty parameters - defaultSimulatorNameProperty - defaultExecutionTargetProperty - infoProperty - customSimulatorFactory defaultSimulator createArgument context entryPoint - mainMethod context entryPoint + submitMethod context entryPoint + simulateMethod context entryPoint ] - let baseName = sprintf "%s.IEntryPoint<%s, %s>" driverNamespace argTypeName returnTypeName - ``class`` entryPointClassName``<<`` [] ``>>`` + let baseName = sprintf "%s.IEntryPoint" driverNamespace + ``class`` ((entryPointClassFullName entryPoint).Name) ``<<`` [] ``>>`` ``:`` (Some (simpleBase baseName)) ``,`` [] [``internal``] ``{`` members ``}`` -/// Generates C# source code for a standalone executable that runs the Q# entry point. -let generate context (entryPoint : QsCallable) = - let ns = - ``namespace`` entryPoint.FullName.Namespace +/// Generates a namespace for a set of entry points that share the namespace +let private entryPointNamespace context name entryPoints = + ``namespace`` name + ``{`` + [] + [for ep in entryPoints -> entryPointClass context ep] + ``}`` + +/// Returns the driver settings object. +let private driverSettings context = + let newDriverSettings = driverNamespace + ".DriverSettings" |> ``type`` |> SyntaxFactory.ObjectCreationExpression + let namedArg (name : string) expr = SyntaxFactory.NameColon name |> (SyntaxFactory.Argument expr).WithNameColon + let immutableList elements = invoke (ident "System.Collections.Immutable.ImmutableList.Create") ``(`` elements ``)`` + let simulatorOptionAliases = + [ literal <| "--" + fst CommandLineArguments.SimulatorOption + literal <| "-" + snd CommandLineArguments.SimulatorOption ] + |> immutableList + let defaultSimulator = + context.assemblyConstants.TryGetValue AssemblyConstants.DefaultSimulator + |> fun (_, value) -> if String.IsNullOrWhiteSpace value then AssemblyConstants.QuantumSimulator else value + let defaultExecutionTarget = + context.assemblyConstants.TryGetValue AssemblyConstants.ExecutionTarget + |> (fun (_, value) -> if value = null then "" else value) + |> literal + [ + namedArg "simulatorOptionAliases" simulatorOptionAliases + namedArg "quantumSimulatorName" <| literal AssemblyConstants.QuantumSimulator + namedArg "toffoliSimulatorName" <| literal AssemblyConstants.ToffoliSimulator + namedArg "resourcesEstimatorName" <| literal AssemblyConstants.ResourcesEstimator + namedArg "defaultSimulatorName" <| literal defaultSimulator + namedArg "defaultExecutionTarget" <| defaultExecutionTarget + namedArg "createDefaultCustomSimulator" <| customSimulatorFactory defaultSimulator + ] + |> SyntaxFactory.SeparatedList + |> SyntaxFactory.ArgumentList + |> newDriverSettings.WithArgumentList + :> ExpressionSyntax + +/// The main method for the standalone executable. +let private mainMethod context entryPoints = + + let entryPointArrayMembers = + [ + for ep in entryPoints do + let name = entryPointClassFullName ep + ``new`` (``type`` (name.ToString())) ``(`` [] ``)`` + ] + + let entryPointArray = + ``new array`` (Some (driverNamespace + ".IEntryPoint")) entryPointArrayMembers + + let driver = ``new`` (``type`` (driverNamespace + ".Driver")) ``(`` [driverSettings context; entryPointArray] ``)`` + let commandLineArgsName = "args" + arrow_method "System.Threading.Tasks.Task" "Main" ``<<`` [] ``>>`` + ``(`` [param commandLineArgsName ``of`` (``type`` "string[]")] ``)`` + [``private``; ``static``; async] + (Some (``=>`` (await (driver <.> (ident "Run", [ident commandLineArgsName]))))) + +/// Generates a namespace for the main function +let private mainNamespace context entryPoints = + let mainClass = + ``class`` entryPointClassName ``<<`` [] ``>>`` + ``:`` None ``,`` [] + [``internal``] ``{`` - (Seq.map using SimulationCode.autoNamespaces) - [entryPointClass context entryPoint] + [mainMethod context entryPoints] ``}`` - ``compilation unit`` [] [] [ns] + + ``namespace`` entryPointClassName + ``{`` + [] + [mainClass] + ``}`` + +/// Generates the C# source code for the file containing the Main function. +let generateMainSource context entryPoints = + let mainNS = mainNamespace context entryPoints + ``compilation unit`` [] (Seq.map using SimulationCode.autoNamespaces) [mainNS :> MemberDeclarationSyntax] + |> ``with leading comments`` SimulationCode.autogenComment + |> SimulationCode.formatSyntaxTree + +/// Generates C# source code for a standalone executable that runs the Q# entry point. +let generateSource context (entryPoints : seq) = + let entryPointNamespaces = entryPoints |> Seq.groupBy (fun ep -> ep.FullName.Namespace) + let namespaces = [for ns, eps in entryPointNamespaces -> entryPointNamespace context ns eps :> MemberDeclarationSyntax] + ``compilation unit`` [] (Seq.map using SimulationCode.autoNamespaces) namespaces |> ``with leading comments`` SimulationCode.autogenComment |> SimulationCode.formatSyntaxTree diff --git a/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj b/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj index c85fc9bce0b..40ae7fd44c1 100644 --- a/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj +++ b/src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj @@ -1,4 +1,4 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/src/Simulation/CSharpGeneration/RewriteStep.fs b/src/Simulation/CSharpGeneration/RewriteStep.fs index 47e35baf0ca..10ea2242f05 100644 --- a/src/Simulation/CSharpGeneration/RewriteStep.fs +++ b/src/Simulation/CSharpGeneration/RewriteStep.fs @@ -6,11 +6,9 @@ namespace Microsoft.Quantum.QsCompiler.CsharpGeneration open System open System.Collections.Generic open System.IO -open Microsoft.CodeAnalysis open Microsoft.Quantum.QsCompiler +open Microsoft.Quantum.QsCompiler.CompilationBuilder open Microsoft.Quantum.QsCompiler.CsharpGeneration -open Microsoft.Quantum.QsCompiler.DataTypes -open Microsoft.Quantum.QsCompiler.Diagnostics open Microsoft.Quantum.QsCompiler.ReservedKeywords open Microsoft.Quantum.QsCompiler.SyntaxTree open Microsoft.Quantum.QsCompiler.Transformations.BasicTransformations @@ -19,39 +17,29 @@ open Microsoft.Quantum.QsCompiler.Transformations.BasicTransformations type Emitter() = let _AssemblyConstants = new Dictionary<_, _>() - let mutable _Diagnostics = [] interface IRewriteStep with member this.Name = "CSharpGeneration" member this.Priority = -1 // doesn't matter because this rewrite step is the only one in the dll member this.AssemblyConstants = upcast _AssemblyConstants - member this.GeneratedDiagnostics = upcast _Diagnostics - - member this.ImplementsPreconditionVerification = true + member this.GeneratedDiagnostics = Seq.empty + + member this.ImplementsPreconditionVerification = false member this.ImplementsPostconditionVerification = false member this.ImplementsTransformation = true - member this.PreconditionVerification compilation = - if compilation.EntryPoints.Length > 1 then - _Diagnostics <- IRewriteStep.Diagnostic - (Message = DiagnosticItem.Message (ErrorCode.MultipleEntryPoints, []), - Severity = DiagnosticSeverity.Error, - Stage = IRewriteStep.Stage.PreconditionVerification) :: _Diagnostics - false - else - true - + member this.PreconditionVerification _ = NotImplementedException() |> raise member this.PostconditionVerification _ = NotImplementedException() |> raise - - member this.Transformation (compilation, transformed) = + + member this.Transformation (compilation, transformed) = let step = this :> IRewriteStep let dir = step.AssemblyConstants.TryGetValue AssemblyConstants.OutputPath |> function | true, outputFolder when outputFolder <> null -> Path.Combine(outputFolder, "src") | _ -> step.Name let context = CodegenContext.Create (compilation, step.AssemblyConstants) - let allSources = GetSourceFiles.Apply compilation.Namespaces + let allSources = GetSourceFiles.Apply compilation.Namespaces for source in allSources |> Seq.filter context.GenerateCodeForSource do let content = SimulationCode.generate source context @@ -61,9 +49,22 @@ type Emitter() = if content <> null then CompilationLoader.GeneratedFile(source, dir, ".dll.g.cs", content) |> ignore if not compilation.EntryPoints.IsEmpty then - let callable = context.allCallables.[Seq.exactlyOne compilation.EntryPoints] - let content = EntryPoint.generate context callable - CompilationLoader.GeneratedFile(callable.SourceFile, dir, ".EntryPoint.g.cs", content) |> ignore + + let entryPointCallables = + compilation.EntryPoints + |> Seq.map (fun ep -> context.allCallables.[ep]) + + let entryPointSources = + entryPointCallables + |> Seq.groupBy (fun ep -> ep.Source.CodeFile) + + let mainSourceFile = (dir, "EntryPoint") |> Path.Combine |> Path.GetFullPath |> Uri |> CompilationUnitManager.GetFileId + let content = EntryPoint.generateMainSource context entryPointCallables + CompilationLoader.GeneratedFile(mainSourceFile, dir, ".g.Main.cs", content) |> ignore + + for (sourceFile, callables) in entryPointSources do + let content = EntryPoint.generateSource context callables + CompilationLoader.GeneratedFile(sourceFile, dir, ".g.EntryPoint.cs", content) |> ignore transformed <- compilation true diff --git a/src/Simulation/Common/Simulators.Dev.props b/src/Simulation/Common/Simulators.Dev.props index b4eead59d87..62a9ed4319b 100644 --- a/src/Simulation/Common/Simulators.Dev.props +++ b/src/Simulation/Common/Simulators.Dev.props @@ -31,7 +31,7 @@ - + diff --git a/src/Simulation/EntryPointDriver.Tests/Tests.fs b/src/Simulation/EntryPointDriver.Tests/Tests.fs index 3cfb17f8a14..9ca3ad61330 100644 --- a/src/Simulation/EntryPointDriver.Tests/Tests.fs +++ b/src/Simulation/EntryPointDriver.Tests/Tests.fs @@ -70,10 +70,11 @@ let private compileQSharp source = /// Generates C# source code from the compiled Q# syntax tree using the given assembly constants. let private generateCSharp constants (compilation : QsCompilation) = let context = CodegenContext.Create (compilation, constants) - let entryPoint = context.allCallables.[Seq.exactlyOne compilation.EntryPoints] + let entryPoints = seq { for ep in compilation.EntryPoints -> context.allCallables.[ep] } [ SimulationCode.generate testFile context - EntryPoint.generate context entryPoint + EntryPoint.generateSource context entryPoints + EntryPoint.generateMainSource context entryPoints ] /// The full path to a referenced assembly given its short name. @@ -128,7 +129,7 @@ let private testAssembly testName constants = /// Runs the entry point in the assembly with the given command-line arguments, and returns the output, errors, and exit /// code. let private run (assembly : Assembly) (args : string[]) = - let entryPoint = assembly.GetType (sprintf "%s.%s" testNamespace EntryPoint.entryPointClassName) + let entryPoint = assembly.GetType (sprintf "%s.%s" EntryPoint.entryPointClassName EntryPoint.entryPointClassName) let main = entryPoint.GetMethod("Main", BindingFlags.NonPublic ||| BindingFlags.Static) let previousCulture = CultureInfo.DefaultThreadCurrentCulture let previousOut = Console.Out @@ -191,7 +192,7 @@ let private testWithTarget defaultTarget = |> testWithConstants /// Standard command-line arguments for the "submit" command without specifying a target. -let private submitWithoutTarget = +let private submitWithoutTarget = [ "submit" "--subscription" "mySubscription" @@ -420,7 +421,7 @@ let ``Accepts one-tuple`` () = let given = test "Accepts one-tuple" given ["-x"; "7"; "-y"; "8"] |> yields "7 8" -[] +[] let ``Accepts two-tuple`` () = let given = test "Accepts two-tuple" given ["-x"; "7"; "-y"; "8"; "-z"; "9"] |> yields "7 8 9" @@ -451,7 +452,7 @@ let ``Shadows --simulator`` () = |> yields (sprintf "Warning: Option --simulator is overridden by an entry point parameter name. Using default value QuantumSimulator. %s" AssemblyConstants.ResourcesEstimator) - given ["-s"; AssemblyConstants.ResourcesEstimator; "--simulator"; "foo"] |> fails + given ["-s"; AssemblyConstants.ResourcesEstimator; "--simulator"; "foo"] |> fails given ["-s"; "foo"] |> fails [] @@ -836,6 +837,9 @@ let ``Shows help text for submit command`` () = %s submit [options] Options: + -n (REQUIRED) A number. + --pauli (REQUIRED) The name of a Pauli matrix. + --my-cool-bool (REQUIRED) A neat bit. --subscription (REQUIRED) The subscription ID. --resource-group (REQUIRED) The resource group name. --workspace (REQUIRED) The workspace name. @@ -849,9 +853,6 @@ let ``Shows help text for submit command`` () = --output The information to show in the output after the job is submitted. --dry-run Validate the program and options, but do not submit to Azure Quantum. --verbose Show additional information about the submission. - -n (REQUIRED) A number. - --pauli (REQUIRED) The name of a Pauli matrix. - --my-cool-bool (REQUIRED) A neat bit. -?, -h, --help Show help and usage information" let given = test "Help" given ["submit"; "--help"] |> yields message @@ -865,6 +866,9 @@ let ``Shows help text for submit command with default target`` () = %s submit [options] Options: + -n (REQUIRED) A number. + --pauli (REQUIRED) The name of a Pauli matrix. + --my-cool-bool (REQUIRED) A neat bit. --subscription (REQUIRED) The subscription ID. --resource-group (REQUIRED) The resource group name. --workspace (REQUIRED) The workspace name. @@ -878,9 +882,98 @@ let ``Shows help text for submit command with default target`` () = --output The information to show in the output after the job is submitted. --dry-run Validate the program and options, but do not submit to Azure Quantum. --verbose Show additional information about the submission. - -n (REQUIRED) A number. - --pauli (REQUIRED) The name of a Pauli matrix. - --my-cool-bool (REQUIRED) A neat bit. -?, -h, --help Show help and usage information" let given = testWithTarget "foo.target" "Help" given ["submit"; "--help"] |> yields message + +[] +let ``Supports simulating multiple entry points`` () = + let given = test "Multiple entry points" + given ["simulate"; "EntryPointTest.MultipleEntryPoints1"] |> yields "Hello from Entry Point 1!" + given ["simulate"; "EntryPointTest.MultipleEntryPoints2"] |> yields "Hello from Entry Point 2!" + given ["simulate"; "EntryPointTest3.MultipleEntryPoints3"] |> yields "Hello from Entry Point 3!" + given ["simulate"] |> fails + given [] |> fails + +[] +let ``Supports simulating multiple entry points with different parameters`` () = + let given = test "Multiple entry points with different parameters" + let entryPoint1Args = ["-n"; "42.5"] + let entryPoint2Args = ["-s"; "Hello, World!"] + let entryPoint3Args = ["-i"; "3"] + + given (["simulate"; "EntryPointTest.MultipleEntryPoints1"] @ entryPoint1Args) |> yields "42.5" + given (["simulate"; "EntryPointTest.MultipleEntryPoints1"] @ entryPoint2Args) |> fails + given (["simulate"; "EntryPointTest.MultipleEntryPoints1"] @ entryPoint3Args) |> fails + given ["simulate"; "EntryPointTest.MultipleEntryPoints1"] |> fails + + given (["simulate"; "EntryPointTest.MultipleEntryPoints2"] @ entryPoint1Args) |> fails + given (["simulate"; "EntryPointTest.MultipleEntryPoints2"] @ entryPoint2Args) |> yields "Hello, World!" + given (["simulate"; "EntryPointTest.MultipleEntryPoints2"] @ entryPoint3Args) |> fails + given ["simulate"; "EntryPointTest.MultipleEntryPoints2"] |> fails + + given (["simulate"; "EntryPointTest3.MultipleEntryPoints3"] @ entryPoint1Args) |> fails + given (["simulate"; "EntryPointTest3.MultipleEntryPoints3"] @ entryPoint2Args) |> fails + given (["simulate"; "EntryPointTest3.MultipleEntryPoints3"] @ entryPoint3Args) |> yields "3" + given ["simulate"; "EntryPointTest3.MultipleEntryPoints3"] |> fails + + given ["simulate"] |> fails + given [] |> fails + +[] +let ``Supports submitting multiple entry points`` () = + let options = + [ + "--subscription" + "mySubscription" + "--resource-group" + "myResourceGroup" + "--workspace" + "myWorkspace" + "--target" + "test.nothing" + ] + let given = test "Multiple entry points" + let succeeds = yields "https://www.example.com/00000000-0000-0000-0000-0000000000000" + given (["submit"; "EntryPointTest.MultipleEntryPoints1"] @ options) |> succeeds + given (["submit"; "EntryPointTest.MultipleEntryPoints2"] @ options) |> succeeds + given (["submit"; "EntryPointTest3.MultipleEntryPoints3"] @ options) |> succeeds + given (["submit"] @ options) |> fails + given [] |> fails + +[] +let ``Supports submitting multiple entry points with different parameters`` () = + let options = + [ + "--subscription" + "mySubscription" + "--resource-group" + "myResourceGroup" + "--workspace" + "myWorkspace" + "--target" + "test.nothing" + ] + let entryPoint1Args = ["-n"; "42.5"] + let entryPoint2Args = ["-s"; "Hello, World!"] + let entryPoint3Args = ["-i"; "3"] + let given = test "Multiple entry points with different parameters" + let succeeds = yields "https://www.example.com/00000000-0000-0000-0000-0000000000000" + + given (["submit"; "EntryPointTest.MultipleEntryPoints1"] @ entryPoint1Args @ options) |> succeeds + given (["submit"; "EntryPointTest.MultipleEntryPoints1"] @ entryPoint2Args @ options) |> fails + given (["submit"; "EntryPointTest.MultipleEntryPoints1"] @ entryPoint3Args @ options) |> fails + given (["submit"; "EntryPointTest.MultipleEntryPoints1"] @ options) |> fails + + given (["submit"; "EntryPointTest.MultipleEntryPoints2"] @ entryPoint1Args @ options) |> fails + given (["submit"; "EntryPointTest.MultipleEntryPoints2"] @ entryPoint2Args @ options) |> succeeds + given (["submit"; "EntryPointTest.MultipleEntryPoints2"] @ entryPoint3Args @ options) |> fails + given (["submit"; "EntryPointTest.MultipleEntryPoints2"] @ options) |> fails + + given (["submit"; "EntryPointTest3.MultipleEntryPoints3"] @ entryPoint1Args @ options) |> fails + given (["submit"; "EntryPointTest3.MultipleEntryPoints3"] @ entryPoint2Args @ options) |> fails + given (["submit"; "EntryPointTest3.MultipleEntryPoints3"] @ entryPoint3Args @ options) |> succeeds + given (["submit"; "EntryPointTest3.MultipleEntryPoints3"] @ options) |> fails + + given submitWithNothingTarget |> fails + given [] |> fails diff --git a/src/Simulation/EntryPointDriver.Tests/Tests.qs b/src/Simulation/EntryPointDriver.Tests/Tests.qs index 516f8bca50d..bc05e62be83 100644 --- a/src/Simulation/EntryPointDriver.Tests/Tests.qs +++ b/src/Simulation/EntryPointDriver.Tests/Tests.qs @@ -360,3 +360,49 @@ namespace EntryPointTest { @EntryPoint() operation Help(n : Int, pauli : Pauli, myCoolBool : Bool) : Unit { } } + +// +// Multiple Entry Points +// + +// --- Multiple entry points + +namespace EntryPointTest { + @EntryPoint() + operation MultipleEntryPoints1() : String { + return "Hello from Entry Point 1!"; + } + + @EntryPoint() + operation MultipleEntryPoints2() : String { + return "Hello from Entry Point 2!"; + } +} + +namespace EntryPointTest3 { + @EntryPoint() + operation MultipleEntryPoints3() : String { + return "Hello from Entry Point 3!"; + } +} + +// --- Multiple entry points with different parameters + +namespace EntryPointTest { + @EntryPoint() + operation MultipleEntryPoints1(n : Double) : Double { + return n; + } + + @EntryPoint() + operation MultipleEntryPoints2(s : String) : String { + return s; + } +} + +namespace EntryPointTest3 { + @EntryPoint() + operation MultipleEntryPoints3(i : Int) : Int { + return i; + } +} diff --git a/src/Simulation/EntryPointDriver/Azure.cs b/src/Simulation/EntryPointDriver/Azure.cs index e94624f5602..9f33f7baec5 100644 --- a/src/Simulation/EntryPointDriver/Azure.cs +++ b/src/Simulation/EntryPointDriver/Azure.cs @@ -2,13 +2,13 @@ // Licensed under the MIT License. using System; -using System.CommandLine.Parsing; using System.Linq; using System.Threading.Tasks; using Microsoft.Azure.Quantum; using Microsoft.Azure.Quantum.Exceptions; using Microsoft.Quantum.Runtime; using Microsoft.Quantum.Simulation.Common.Exceptions; +using Microsoft.Quantum.Simulation.Core; using static Microsoft.Quantum.EntryPointDriver.Driver; namespace Microsoft.Quantum.EntryPointDriver @@ -16,19 +16,18 @@ namespace Microsoft.Quantum.EntryPointDriver /// /// Provides entry point submission to Azure Quantum. /// - internal static class Azure + public static class Azure { /// /// Submits the entry point to Azure Quantum. /// - /// The entry point. - /// The command-line parsing result. - /// The submission settings. /// The entry point's argument type. /// The entry point's return type. + /// The information about the entry point. + /// The input argument tuple to the entry point. + /// The submission settings. /// The exit code. - internal static async Task Submit( - IEntryPoint entryPoint, ParseResult parseResult, AzureSettings settings) + public static async Task Submit(EntryPointInfo info, TIn input, AzureSettings settings) { if (settings.Verbose) { @@ -44,28 +43,27 @@ internal static async Task Submit( return 1; } - var input = entryPoint.CreateArgument(parseResult); return settings.DryRun - ? Validate(machine, entryPoint, input) - : await SubmitJob(machine, entryPoint, input, settings); + ? Validate(machine, info, input) + : await SubmitJob(machine, info, input, settings); } /// /// Submits a job to Azure Quantum. /// - /// The quantum machine target. - /// The program entry point. - /// The program input. - /// The submission settings. /// The input type. /// The output type. + /// The quantum machine target. + /// The information about the entry point. + /// The input argument tuple to the entry point. + /// The submission settings. /// The exit code. private static async Task SubmitJob( - IQuantumMachine machine, IEntryPoint entryPoint, TIn input, AzureSettings settings) + IQuantumMachine machine, EntryPointInfo info, TIn input, AzureSettings settings) { try { - var job = await machine.SubmitAsync(entryPoint.Info, input, new SubmissionContext + var job = await machine.SubmitAsync(info, input, new SubmissionContext { FriendlyName = settings.JobName, Shots = settings.Shots @@ -93,15 +91,15 @@ private static async Task SubmitJob( /// /// Validates the program for the quantum machine target. /// - /// The quantum machine target. - /// The program entry point. - /// The program input. /// The input type. /// The output type. + /// The quantum machine target. + /// The information about the entry point. + /// The input argument tuple to the entry point. /// The exit code. - private static int Validate(IQuantumMachine machine, IEntryPoint entryPoint, TIn input) + private static int Validate(IQuantumMachine machine, EntryPointInfo info, TIn input) { - var (isValid, message) = machine.Validate(entryPoint.Info, input); + var (isValid, message) = machine.Validate(info, input); Console.WriteLine(isValid ? "✔️ The program is valid!" : "❌ The program is invalid."); if (!string.IsNullOrWhiteSpace(message)) { @@ -186,7 +184,7 @@ private sealed class SubmissionContext : IQuantumMachineSubmissionContext /// /// The information to show in the output after the job is submitted. /// - internal enum OutputFormat + public enum OutputFormat { /// /// Show a friendly message with a URI that can be used to see the job results. @@ -202,7 +200,7 @@ internal enum OutputFormat /// /// Settings for a submission to Azure Quantum. /// - internal sealed class AzureSettings + public sealed class AzureSettings { /// /// The subscription ID. diff --git a/src/Simulation/EntryPointDriver/Driver.cs b/src/Simulation/EntryPointDriver/Driver.cs index fa521c50b80..7997a87db01 100644 --- a/src/Simulation/EntryPointDriver/Driver.cs +++ b/src/Simulation/EntryPointDriver/Driver.cs @@ -13,66 +13,161 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Quantum.Simulation.Core; -using static Microsoft.Quantum.EntryPointDriver.Driver; namespace Microsoft.Quantum.EntryPointDriver { + using Validators = ImmutableList>; + /// - /// The entry point driver is the entry point for the C# application that executes the Q# entry point. + /// The entry point driver is the entry point for the C# application that executes Q# entry points. /// - /// The entry point's callable type. - /// The entry point's argument type. - /// The entry point's return type. - public sealed class Driver where TCallable : AbstractCallable, ICallable + public sealed class Driver { /// - /// The driver settings. + /// The subscription option. /// - private readonly DriverSettings settings; + private static readonly OptionInfo SubscriptionOption = new OptionInfo( + ImmutableList.Create("--subscription"), "The subscription ID."); /// - /// The entry point. + /// The resource group option. /// - private readonly IEntryPoint entryPoint; + private static readonly OptionInfo ResourceGroupOption = new OptionInfo( + ImmutableList.Create("--resource-group"), "The resource group name."); /// - /// The simulator option. + /// The workspace option. + /// + private static readonly OptionInfo WorkspaceOption = new OptionInfo( + ImmutableList.Create("--workspace"), "The workspace name."); + + /// + /// The storage option. + /// + private static readonly OptionInfo StorageOption = new OptionInfo( + ImmutableList.Create("--storage"), default, "The storage account connection string."); + + /// + /// The AAD token option. /// - private OptionInfo SimulatorOption { get; } + private static readonly OptionInfo AadTokenOption = new OptionInfo( + ImmutableList.Create("--aad-token"), default, "The Azure Active Directory authentication token."); + + /// + /// The base URI option. + /// + private static readonly OptionInfo BaseUriOption = new OptionInfo( + ImmutableList.Create("--base-uri"), default, "The base URI of the Azure Quantum endpoint."); + + /// + /// The location to use with the default endpoint option. + /// + private static readonly OptionInfo LocationOption = new OptionInfo( + ImmutableList.Create("--location"), + default, + "The location to use with the default endpoint.", + validator: result => + { + var location = result.Tokens.SingleOrDefault()?.Value; + if (location == null) + { + return default; + } + + var normalizedLocation = AzureSettings.NormalizeLocation(location); + return Uri.CheckHostName(normalizedLocation) == UriHostNameType.Unknown ? + $"\"{location}\" is an invalid value for the --location option." : + default; + }); + + /// + /// The job name option. + /// + private static readonly OptionInfo JobNameOption = new OptionInfo( + ImmutableList.Create("--job-name"), default, "The name of the submitted job."); + + /// + /// The shots option. + /// + private static readonly OptionInfo ShotsOption = new OptionInfo( + ImmutableList.Create("--shots"), + 500, + "The number of times the program is executed on the target machine.", + validator: result => + int.TryParse(result.Tokens.SingleOrDefault()?.Value, out var value) && value <= 0 + ? "The number of shots must be a positive number." + : default); + + /// + /// The output option. + /// + private static readonly OptionInfo OutputOption = new OptionInfo( + ImmutableList.Create("--output"), + OutputFormat.FriendlyUri, + "The information to show in the output after the job is submitted."); + + /// + /// The dry run option. + /// + private static readonly OptionInfo DryRunOption = new OptionInfo( + ImmutableList.Create("--dry-run"), + false, + "Validate the program and options, but do not submit to Azure Quantum."); + + /// + /// The verbose option. + /// + private static readonly OptionInfo VerboseOption = new OptionInfo( + ImmutableList.Create("--verbose"), false, "Show additional information about the submission."); /// /// The target option. /// - private OptionInfo TargetOption { get; } + private readonly OptionInfo TargetOption; + + /// + /// The simulator option. + /// + private readonly OptionInfo SimulatorOption; + + /// + /// The driver settings. + /// + private readonly DriverSettings settings; + + /// + /// All the registered entry points of the program. + /// + private readonly IReadOnlyCollection entryPoints; /// /// Creates a new driver for the entry point. /// /// The driver settings. - /// The entry point. - public Driver(DriverSettings settings, IEntryPoint entryPoint) + /// The entry points. + public Driver(DriverSettings settings, IReadOnlyCollection entryPoints) { this.settings = settings; - this.entryPoint = entryPoint; - SimulatorOption = new OptionInfo( - settings.SimulatorOptionAliases, - entryPoint.DefaultSimulatorName, + this.SimulatorOption = new OptionInfo( + this.settings.SimulatorOptionAliases, + this.settings.DefaultSimulatorName, "The name of the simulator to use.", suggestions: new[] { - settings.QuantumSimulatorName, - settings.ToffoliSimulatorName, - settings.ResourcesEstimatorName, - entryPoint.DefaultSimulatorName + this.settings.QuantumSimulatorName, + this.settings.ToffoliSimulatorName, + this.settings.ResourcesEstimatorName, + this.settings.DefaultSimulatorName }); var targetAliases = ImmutableList.Create("--target"); const string targetDescription = "The target device ID."; - TargetOption = string.IsNullOrWhiteSpace(entryPoint.DefaultExecutionTarget) + this.TargetOption = string.IsNullOrWhiteSpace(settings.DefaultExecutionTarget) ? new OptionInfo(targetAliases, targetDescription) - : new OptionInfo(targetAliases, entryPoint.DefaultExecutionTarget, targetDescription); + : new OptionInfo(targetAliases, this.settings.DefaultExecutionTarget, targetDescription); + + this.entryPoints = entryPoints; } /// @@ -82,46 +177,18 @@ public Driver(DriverSettings settings, IEntryPoint entryPoint) /// The exit code. public async Task Run(string[] args) { - var simulate = new Command("simulate", "(default) Run the program using a local simulator.") - { - Handler = CommandHandler.Create(Simulate) - }; - AddOptionIfAvailable(simulate, SimulatorOption); + var simulateSubCommands = this.entryPoints.Select(this.CreateSimulateEntryPointCommand).ToList(); + var submitSubCommands = this.entryPoints.Select(this.CreateSubmitEntryPointCommand).ToList(); - var submit = new Command("submit", "Submit the program to Azure Quantum.") - { - IsHidden = true, - Handler = CommandHandler.Create(Submit) - }; - AddOptionIfAvailable(submit, SubscriptionOption); - AddOptionIfAvailable(submit, ResourceGroupOption); - AddOptionIfAvailable(submit, WorkspaceOption); - AddOptionIfAvailable(submit, TargetOption); - AddOptionIfAvailable(submit, StorageOption); - AddOptionIfAvailable(submit, AadTokenOption); - AddOptionIfAvailable(submit, BaseUriOption); - AddOptionIfAvailable(submit, LocationOption); - AddOptionIfAvailable(submit, JobNameOption); - AddOptionIfAvailable(submit, ShotsOption); - AddOptionIfAvailable(submit, OutputOption); - AddOptionIfAvailable(submit, DryRunOption); - AddOptionIfAvailable(submit, VerboseOption); - MarkOptionsAsMutuallyExclusive( - submit, - new[] { BaseUriOption.Aliases.First(), LocationOption.Aliases.First() }); - - var root = new RootCommand(entryPoint.Summary) { simulate, submit }; - foreach (var option in entryPoint.Options) - { - root.AddGlobalOption(option); - } + var simulate = CreateSimulateCommand(simulateSubCommands); + var submit = CreateSubmitCommand(submitSubCommands); - // Set the simulate command as the default. - foreach (var option in simulate.Options) + var root = new RootCommand() { simulate.Command, submit.Command }; + if (this.entryPoints.Count() == 1) { - root.AddOption(option); + SetSubCommandAsDefault(root, simulate.Command, simulate.Validators); + root.Description = this.entryPoints.First().Summary; } - root.Handler = simulate.Handler; Console.OutputEncoding = Encoding.UTF8; return await new CommandLineBuilder(root) @@ -132,57 +199,59 @@ public async Task Run(string[] args) } /// - /// Simulates the entry point. + /// Displays a message to the console using the given color and text writer. /// - /// The command-line parsing result. - /// The simulator to use. - /// The exit code. - private async Task Simulate(ParseResult parseResult, string simulator) => - await Simulation.Simulate( - settings, entryPoint, parseResult, DefaultIfShadowed(SimulatorOption, simulator)); + /// The text color. + /// The text writer for the console output stream. + /// The message to display. + internal static void DisplayWithColor(ConsoleColor color, TextWriter writer, string message) + { + var originalForeground = Console.ForegroundColor; + Console.ForegroundColor = color; + writer.WriteLine(message); + Console.ForegroundColor = originalForeground; + } /// - /// Submits the entry point to Azure Quantum. + /// Copies the handle and options from the given sub command to the given command. /// - /// The command-line parsing result. - /// The Azure submission settings. - private async Task Submit(ParseResult parseResult, AzureSettings azureSettings) => - await Azure.Submit(entryPoint, parseResult, new AzureSettings + /// The command whose handle and options will be set. + /// The sub command that will be copied from. + /// The validators associated with the sub command. + private static void SetSubCommandAsDefault(Command root, Command subCommand, Validators validators) + { + root.Handler = subCommand.Handler; + foreach (var option in subCommand.Options) { - Subscription = azureSettings.Subscription, - ResourceGroup = azureSettings.ResourceGroup, - Workspace = azureSettings.Workspace, - Target = DefaultIfShadowed(TargetOption, azureSettings.Target), - Storage = DefaultIfShadowed(StorageOption, azureSettings.Storage), - AadToken = DefaultIfShadowed(AadTokenOption, azureSettings.AadToken), - BaseUri = DefaultIfShadowed(BaseUriOption, azureSettings.BaseUri), - Location = DefaultIfShadowed(LocationOption, azureSettings.Location), - JobName = DefaultIfShadowed(JobNameOption, azureSettings.JobName), - Shots = DefaultIfShadowed(ShotsOption, azureSettings.Shots), - Output = DefaultIfShadowed(OutputOption, azureSettings.Output), - DryRun = DefaultIfShadowed(DryRunOption, azureSettings.DryRun), - Verbose = DefaultIfShadowed(VerboseOption, azureSettings.Verbose) - }); + root.AddOption(option); + } + foreach (var validator in validators) + { + root.AddValidator(validator); + } + } /// - /// Returns true if the alias is not already used by an entry point option. + /// Returns true if the alias is not already used by an existing option. /// /// The alias to check. + /// Existing options to check against. /// True if the alias is available for use by the driver. - private bool IsAliasAvailable(string alias) => - !entryPoint.Options.SelectMany(option => option.RawAliases).Contains(alias); + private static bool IsAliasAvailable(string alias, IEnumerable + /// The type of the option's argument. /// The command to add the option to. /// The option to add. - /// The type of the option's argument. - private void AddOptionIfAvailable(Command command, OptionInfo option) + /// The list of validators added to the command during this function. + private static Validators AddOptionIfAvailable(Command command, OptionInfo option) { - if (IsAliasAvailable(option.Aliases.First())) + if (IsAliasAvailable(option.Aliases.First(), command.Options)) { - command.AddOption(option.Create(option.Aliases.Where(IsAliasAvailable))); + command.AddOption(option.Create(option.Aliases.Where(alias => IsAliasAvailable(alias, command.Options)))); } else if (option.Required) { - command.AddValidator(commandResult => - $"The required option {option.Aliases.First()} conflicts with an entry point parameter name."); + ValidateSymbol validator = commandResult => + $"The required option {option.Aliases.First()} conflicts with an entry point parameter name."; + + command.AddValidator(validator); + return ImmutableList.Create(validator); } + + return Validators.Empty; } /// @@ -220,8 +295,10 @@ private void AddOptionIfAvailable(Command command, OptionInfo option) /// /// The command to add the validator to. /// The primary aliases of the options to be marked as mutually exclusive. - private void MarkOptionsAsMutuallyExclusive(Command command, string[] primaryAliases) => - command.AddValidator(result => + /// The list of validators added to the command during this function. + private static Validators MarkOptionsAsMutuallyExclusive(Command command, string[] primaryAliases) + { + ValidateSymbol validator = result => { var presentAliases = new List(); foreach (var rawAlias in primaryAliases) @@ -241,146 +318,194 @@ private void MarkOptionsAsMutuallyExclusive(Command command, string[] primaryAli } return default; - }); - } - - /// - /// Static members for . - /// - internal static class Driver - { - // TODO: Define the aliases as constants. - - /// - /// The subscription option. - /// - internal static readonly OptionInfo SubscriptionOption = new OptionInfo( - ImmutableList.Create("--subscription"), "The subscription ID."); - - /// - /// The resource group option. - /// - internal static readonly OptionInfo ResourceGroupOption = new OptionInfo( - ImmutableList.Create("--resource-group"), "The resource group name."); - - /// - /// The workspace option. - /// - internal static readonly OptionInfo WorkspaceOption = new OptionInfo( - ImmutableList.Create("--workspace"), "The workspace name."); - - /// - /// The storage option. - /// - internal static readonly OptionInfo StorageOption = new OptionInfo( - ImmutableList.Create("--storage"), default, "The storage account connection string."); + }; - /// - /// The AAD token option. - /// - internal static readonly OptionInfo AadTokenOption = new OptionInfo( - ImmutableList.Create("--aad-token"), default, "The Azure Active Directory authentication token."); + command.AddValidator(validator); + return ImmutableList.Create(validator); + } /// - /// The base URI option. + /// Creates the simulate command. /// - internal static readonly OptionInfo BaseUriOption = new OptionInfo( - ImmutableList.Create("--base-uri"), default, "The base URI of the Azure Quantum endpoint."); + /// The entry point commands that will be the sub commands to the created command. + /// The created simulate command with the validators for that command. + private static CommandWithValidators CreateSimulateCommand( + List entryPointCommands) + { + var simulate = new Command("simulate", "(default) Run the program using a local simulator."); + if (entryPointCommands.Count() == 1) + { + var epCommandWValidators = entryPointCommands.First(); + epCommandWValidators.Command.IsHidden = true; + simulate.AddCommand(epCommandWValidators.Command); + SetSubCommandAsDefault(simulate, epCommandWValidators.Command, epCommandWValidators.Validators); + return new CommandWithValidators(simulate, epCommandWValidators.Validators); + } + else + { + foreach (var epCommandWValidators in entryPointCommands) + { + simulate.AddCommand(epCommandWValidators.Command); + } + return new CommandWithValidators(simulate, Validators.Empty); + } + } /// - /// The location to use with the default endpoint option. + /// Creates the Azure submit command. /// - internal static readonly OptionInfo LocationOption = new OptionInfo( - ImmutableList.Create("--location"), - default, - "The location to use with the default endpoint.", - validator: result => + /// The entry point commands that will be the sub commands to the created command. + /// The created submit command with the validators for that command. + private static CommandWithValidators CreateSubmitCommand(List entryPointCommands) + { + var submit = new Command("submit", "Submit the program to Azure Quantum.") + { + IsHidden = true, + }; + if (entryPointCommands.Count() == 1) + { + var epCommandWValidators = entryPointCommands.First(); + epCommandWValidators.Command.IsHidden = true; + submit.AddCommand(epCommandWValidators.Command); + SetSubCommandAsDefault(submit, epCommandWValidators.Command, epCommandWValidators.Validators); + return new CommandWithValidators(submit, epCommandWValidators.Validators); + } + else + { + foreach (var epCommandWValidators in entryPointCommands) { - var location = result.Tokens.SingleOrDefault()?.Value; - if (location == null) - { - return default; - } - - var normalizedLocation = AzureSettings.NormalizeLocation(location); - return Uri.CheckHostName(normalizedLocation) == UriHostNameType.Unknown ? - $"\"{location}\" is an invalid value for the --location option." : - default; - }); + submit.AddCommand(epCommandWValidators.Command); + } + return new CommandWithValidators(submit, Validators.Empty); + } + } /// - /// The job name option. + /// Creates a sub command specific to the given entry point for the simulate command. /// - internal static readonly OptionInfo JobNameOption = new OptionInfo( - ImmutableList.Create("--job-name"), default, "The name of the submitted job."); + /// The entry point to make a command for. + /// The command corresponding to the given entry point with the validators for that command. + private CommandWithValidators CreateSimulateEntryPointCommand(IEntryPoint entryPoint) + { + var command = new Command(entryPoint.Name, entryPoint.Summary) + { + Handler = CommandHandler.Create((ParseResult parseResult, string simulator) => this.Simulate(parseResult, simulator, entryPoint)) + }; + foreach (var option in entryPoint.Options) + { + command.AddOption(option); + } + return new CommandWithValidators(command, AddOptionIfAvailable(command, this.SimulatorOption)); + } /// - /// The shots option. + /// Creates a sub command specific to the given entry point for the submit command. /// - internal static readonly OptionInfo ShotsOption = new OptionInfo( - ImmutableList.Create("--shots"), - 500, - "The number of times the program is executed on the target machine.", - validator: result => - int.TryParse(result.Tokens.SingleOrDefault()?.Value, out var value) && value <= 0 - ? "The number of shots must be a positive number." - : default); + /// The entry point to make a command for. + /// The command corresponding to the given entry point with the validators for that command. + private CommandWithValidators CreateSubmitEntryPointCommand(IEntryPoint entryPoint) + { + var command = new Command(entryPoint.Name, entryPoint.Summary) + { + Handler = CommandHandler.Create((ParseResult parseResult, AzureSettings settings) => this.Submit(parseResult, settings, entryPoint)) + }; + foreach (var option in entryPoint.Options) + { + command.AddOption(option); + } - /// - /// The output option. - /// - internal static readonly OptionInfo OutputOption = new OptionInfo( - ImmutableList.Create("--output"), - OutputFormat.FriendlyUri, - "The information to show in the output after the job is submitted."); + var validators = AddOptionIfAvailable(command, SubscriptionOption) + .Concat(AddOptionIfAvailable(command, ResourceGroupOption)) + .Concat(AddOptionIfAvailable(command, WorkspaceOption)) + .Concat(AddOptionIfAvailable(command, this.TargetOption)) + .Concat(AddOptionIfAvailable(command, StorageOption)) + .Concat(AddOptionIfAvailable(command, AadTokenOption)) + .Concat(AddOptionIfAvailable(command, BaseUriOption)) + .Concat(AddOptionIfAvailable(command, LocationOption)) + .Concat(AddOptionIfAvailable(command, JobNameOption)) + .Concat(AddOptionIfAvailable(command, ShotsOption)) + .Concat(AddOptionIfAvailable(command, OutputOption)) + .Concat(AddOptionIfAvailable(command, DryRunOption)) + .Concat(AddOptionIfAvailable(command, VerboseOption)) + .Concat(MarkOptionsAsMutuallyExclusive( + command, + new[] { BaseUriOption.Aliases.First(), LocationOption.Aliases.First() })); + + return new CommandWithValidators(command, validators.ToImmutableList()); + } /// - /// The dry run option. + /// Simulates the entry point. /// - internal static readonly OptionInfo DryRunOption = new OptionInfo( - ImmutableList.Create("--dry-run"), - false, - "Validate the program and options, but do not submit to Azure Quantum."); + /// The command-line parsing result. + /// The simulator to use. + /// The entry point to simulate. + /// The exit code. + private Task Simulate(ParseResult parseResult, string simulator, IEntryPoint entryPoint) => + entryPoint.Simulate(parseResult, settings, DefaultIfShadowed(entryPoint, this.SimulatorOption, simulator)); /// - /// The verbose option. + /// Submits the entry point to Azure Quantum. /// - internal static readonly OptionInfo VerboseOption = new OptionInfo( - ImmutableList.Create("--verbose"), false, "Show additional information about the submission."); - + /// The command-line parsing result. + /// The Azure submission settings. + /// The entry point to submit. + /// The exit code. + private Task Submit(ParseResult parseResult, AzureSettings azureSettings, IEntryPoint entryPoint) => + entryPoint.Submit(parseResult, new AzureSettings + { + Subscription = azureSettings.Subscription, + ResourceGroup = azureSettings.ResourceGroup, + Workspace = azureSettings.Workspace, + Target = DefaultIfShadowed(entryPoint, this.TargetOption, azureSettings.Target), + Storage = DefaultIfShadowed(entryPoint, StorageOption, azureSettings.Storage), + AadToken = DefaultIfShadowed(entryPoint, AadTokenOption, azureSettings.AadToken), + BaseUri = DefaultIfShadowed(entryPoint, BaseUriOption, azureSettings.BaseUri), + Location = DefaultIfShadowed(entryPoint, LocationOption, azureSettings.Location), + JobName = DefaultIfShadowed(entryPoint, JobNameOption, azureSettings.JobName), + Shots = DefaultIfShadowed(entryPoint, ShotsOption, azureSettings.Shots), + Output = DefaultIfShadowed(entryPoint, OutputOption, azureSettings.Output), + DryRun = DefaultIfShadowed(entryPoint, DryRunOption, azureSettings.DryRun), + Verbose = DefaultIfShadowed(entryPoint, VerboseOption, azureSettings.Verbose) + }); + /// - /// Displays a message to the console using the given color and text writer. + /// A modification of the command-line class. /// - /// The text color. - /// The text writer for the console output stream. - /// The message to display. - internal static void DisplayWithColor(ConsoleColor color, TextWriter writer, string message) + private sealed class QsHelpBuilder : HelpBuilder { - var originalForeground = Console.ForegroundColor; - Console.ForegroundColor = color; - writer.WriteLine(message); - Console.ForegroundColor = originalForeground; + /// + /// Creates a new help builder using the given console. + /// + /// The console to use. + internal QsHelpBuilder(IConsole console) : base(console) + { + } + + protected override string ArgumentDescriptor(IArgument argument) + { + // Hide long argument descriptors. + var descriptor = base.ArgumentDescriptor(argument); + return descriptor.Length > 30 ? argument.Name : descriptor; + } } - } - /// - /// A modification of the command-line class. - /// - internal sealed class QsHelpBuilder : HelpBuilder - { /// - /// Creates a new help builder using the given console. + /// Struct for housing a command with its validators. /// - /// The console to use. - internal QsHelpBuilder(IConsole console) : base(console) + private struct CommandWithValidators { - } + public Command Command; + public Validators Validators; - protected override string ArgumentDescriptor(IArgument argument) - { - // Hide long argument descriptors. - var descriptor = base.ArgumentDescriptor(argument); - return descriptor.Length > 30 ? argument.Name : descriptor; + /// + /// Basic constructor. + /// + public CommandWithValidators(Command command, Validators validators) + { + Command = command; + Validators = validators; + } } } } diff --git a/src/Simulation/EntryPointDriver/DriverSettings.cs b/src/Simulation/EntryPointDriver/DriverSettings.cs index 17ec8e551a3..cd2402b12d8 100644 --- a/src/Simulation/EntryPointDriver/DriverSettings.cs +++ b/src/Simulation/EntryPointDriver/DriverSettings.cs @@ -1,4 +1,6 @@ -using System.Collections.Immutable; +using Microsoft.Quantum.Simulation.Core; +using System; +using System.Collections.Immutable; namespace Microsoft.Quantum.EntryPointDriver { @@ -27,6 +29,25 @@ public sealed class DriverSettings /// internal string ResourcesEstimatorName { get; } + /// + /// The name of the default simulator to use when simulating the entry point. + /// + internal string DefaultSimulatorName { get; } + + /// + /// The default execution target when to use when submitting the entry point to Azure Quantum. + /// + internal string DefaultExecutionTarget { get; } + + /// + /// Creates an instance of the default simulator if it is a custom simulator. + /// + /// An instance of the default custom simulator. + /// + /// Thrown if the default simulator is not a custom simulator. + /// + internal Func CreateDefaultCustomSimulator; + /// /// Creates a new driver settings instance. /// @@ -34,16 +55,25 @@ public sealed class DriverSettings /// The name of the quantum simulator. /// The name of the Toffoli simulator. /// The name of the resources estimator. + /// The name of the default simulator to use. + /// The name of the default execution target to use. + /// The function for creating a new instance of the default simulator if it is a custom simulator. public DriverSettings( IImmutableList simulatorOptionAliases, string quantumSimulatorName, string toffoliSimulatorName, - string resourcesEstimatorName) + string resourcesEstimatorName, + string defaultSimulatorName, + string defaultExecutionTarget, + Func createDefaultCustomSimulator) { SimulatorOptionAliases = simulatorOptionAliases; QuantumSimulatorName = quantumSimulatorName; ToffoliSimulatorName = toffoliSimulatorName; ResourcesEstimatorName = resourcesEstimatorName; + DefaultSimulatorName = defaultSimulatorName; + DefaultExecutionTarget = defaultExecutionTarget; + CreateDefaultCustomSimulator = createDefaultCustomSimulator; } } } diff --git a/src/Simulation/EntryPointDriver/IEntryPoint.cs b/src/Simulation/EntryPointDriver/IEntryPoint.cs index 1018fc10f89..67964abb05d 100644 --- a/src/Simulation/EntryPointDriver/IEntryPoint.cs +++ b/src/Simulation/EntryPointDriver/IEntryPoint.cs @@ -1,11 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Collections.Generic; using System.CommandLine; using System.CommandLine.Parsing; -using Microsoft.Quantum.Simulation.Core; +using System.Threading.Tasks; namespace Microsoft.Quantum.EntryPointDriver { @@ -16,10 +15,13 @@ namespace Microsoft.Quantum.EntryPointDriver /// Contains entry point properties needed by the command-line interface and allows the entry point to use /// command-line arguments. The implementation of this interface is code-generated. /// - /// The entry point's argument type. - /// The entry point's return type. - public interface IEntryPoint + public interface IEntryPoint { + /// + /// The name of the entry point. + /// + string Name { get; } + /// /// The summary from the entry point's documentation comment. /// @@ -31,34 +33,20 @@ public interface IEntryPoint IEnumerable