├── llvm-build ├── llvm.tag.txt └── header.txt ├── src ├── QsCompiler │ ├── .gitignore │ ├── CSharpGeneration │ │ ├── .gitignore │ │ └── RewriteStep.props │ ├── TestProjects │ │ ├── test12 │ │ │ ├── README.md │ │ │ ├── Operation12a.qs │ │ │ ├── Operation12b.qs │ │ │ ├── format │ │ │ │ ├── Unformatted.qs │ │ │ │ └── Formatted.qs │ │ │ ├── test12.csproj │ │ │ └── sub1 │ │ │ │ ├── Operation12b.qs │ │ │ │ └── sub2 │ │ │ │ └── Operation12a.qs │ │ ├── test14 │ │ │ ├── README.md │ │ │ └── test14.csproj │ │ ├── test17 │ │ │ ├── README.md │ │ │ ├── test17.csproj │ │ │ └── MeasureBell.qs │ │ ├── test15 │ │ │ ├── README.md │ │ │ ├── format │ │ │ │ ├── Unformatted.qs │ │ │ │ └── Formatted.qs │ │ │ └── test15.csproj │ │ ├── README.md │ │ ├── test2 │ │ │ ├── Class1.cs │ │ │ └── test2.csproj │ │ ├── test11 │ │ │ ├── README.md │ │ │ ├── test11.csproj │ │ │ ├── Driver.cs │ │ │ └── Operation11.qs │ │ ├── test16 │ │ │ ├── test16.csproj │ │ │ └── Lambda.qs │ │ ├── test10 │ │ │ ├── test10.csproj │ │ │ └── Operation10.qs │ │ ├── test1 │ │ │ ├── Program.cs │ │ │ └── test1.csproj │ │ ├── test8 │ │ │ └── Class1.cs │ │ ├── test13 │ │ │ ├── Driver.cs │ │ │ ├── Operation13.qs │ │ │ └── test13.csproj │ │ ├── test4 │ │ │ ├── Driver.cs │ │ │ ├── Operation4.qs │ │ │ └── test4.csproj │ │ ├── test9 │ │ │ ├── Driver.cs │ │ │ ├── Operation9.qs │ │ │ └── test9.csproj │ │ ├── test3 │ │ │ ├── Operation3a.qs │ │ │ ├── Operation3b.qs │ │ │ ├── sub1 │ │ │ │ ├── Operation3b.qs │ │ │ │ └── sub2 │ │ │ │ │ └── Operation3a.qs │ │ │ └── test3.csproj │ │ ├── test5 │ │ │ ├── Operation5.qs │ │ │ ├── test.folder │ │ │ │ └── Operation5.qs │ │ │ └── Tests5.qs │ │ ├── test6 │ │ │ ├── Operation6a.qs │ │ │ ├── sub1 │ │ │ │ └── Operation6a.qs │ │ │ └── test6.csproj │ │ └── test7 │ │ │ ├── Operation.qs │ │ │ └── test7.csproj │ ├── Tests.RoslynWrapper │ │ ├── Program.fs │ │ └── README.txt │ ├── LanguageServer │ │ ├── global.language-server.json │ │ └── .editorconfig │ ├── Tests.Compiler │ │ └── TestCases │ │ │ ├── QirTests │ │ │ ├── TestDeclarations3.ll │ │ │ ├── TestGenerics1.ll │ │ │ ├── TestDeclarations4.ll │ │ │ ├── TestLibraryGeneration1.ll │ │ │ ├── TestLibraryGeneration2.ll │ │ │ ├── TestGenerics2.ll │ │ │ ├── TestUsing1.ll │ │ │ ├── TestDeclarations5.ll │ │ │ ├── TestPaulis.ll │ │ │ ├── TestLibraryGeneration3.ll │ │ │ ├── TestPaulis.qs │ │ │ ├── TestWhile.qs │ │ │ ├── TestDoubles.qs │ │ │ ├── TestUdtAccessor.qs │ │ │ ├── TestIntegers.qs │ │ │ ├── TestDeclarations2.ll │ │ │ ├── TestDeclarations6.ll │ │ │ ├── TestResults.qs │ │ │ ├── TestUdt.qs │ │ │ ├── TestGenerics3.ll │ │ │ ├── TestRange.qs │ │ │ ├── TestLibraryGeneration.qs │ │ │ ├── TestDeconstruct.qs │ │ │ ├── TestShortCircuiting.qs │ │ │ ├── TestBools.qs │ │ │ ├── TestGenerics4.ll │ │ │ ├── TestIntegers.ll │ │ │ ├── TestBools.ll │ │ │ ├── TestUdtConstruction.qs │ │ │ ├── RepeatArray.qs │ │ │ ├── TestDeclarations1.ll │ │ │ ├── TestAliasCounts.qs │ │ │ ├── TestControlled2.ll │ │ │ ├── TestStrings.qs │ │ │ ├── TestArrayLoop.qs │ │ │ ├── TestWhile.ll │ │ │ ├── TestConditional5.ll │ │ │ ├── TestUdtArgument.qs │ │ │ ├── TestEntryPoint.qs │ │ │ ├── TestBigInts.qs │ │ │ ├── TestForLoop.qs │ │ │ ├── TestUsing.qs │ │ │ └── TestDeclarations.qs │ │ │ ├── ResultComparison.qs │ │ │ ├── OptimizerTests │ │ │ ├── TypedParameters_output.txt │ │ │ ├── Reordering_output.txt │ │ │ ├── NoOp_output.txt │ │ │ ├── TypedParameters_input.qs │ │ │ ├── Reordering_input.qs │ │ │ ├── NoOp_input.qs │ │ │ ├── Arithmetic_output.txt │ │ │ ├── Inlining_output.txt │ │ │ ├── Inlining_input.qs │ │ │ └── LoopUnrolling_input.qs │ │ │ ├── WholeFileTests │ │ │ ├── ConflictingAliases.qs │ │ │ ├── OpenWithAlias.qs │ │ │ ├── DuplicateOpens.qs │ │ │ └── DuplicateAndConflictingAliases.qs │ │ │ ├── ExecutionTests │ │ │ ├── QirTargetingTests.qs │ │ │ └── Packaging.qs │ │ │ └── AttributeGeneration.qs │ ├── RoslynWrapper │ │ ├── README.txt │ │ ├── cgmanifest.json │ │ ├── App.config │ │ ├── WhileStatement.fs │ │ ├── CodeGenerator.fs │ │ └── Invocation.fs │ ├── Tests.CSharpGeneration │ │ ├── Program.fs │ │ └── Circuits │ │ │ ├── Types.qs │ │ │ ├── Core.qs │ │ │ ├── HelloWorld.qs │ │ │ ├── SubDirectory │ │ │ ├── HelloOther.qs │ │ │ └── HelloWorld.qs │ │ │ ├── EmptyElements.qs │ │ │ ├── TargetedExe.qs │ │ │ ├── LineNumbers.qs │ │ │ └── UnitTests.qs │ ├── Core │ │ ├── Utils.fs │ │ ├── SymbolTable │ │ │ └── SymbolNotFoundException.fs │ │ └── AssemblyInfo.fs │ ├── TestTargets │ │ ├── Libraries │ │ │ ├── build │ │ │ │ └── Library.props │ │ │ ├── Library1 │ │ │ │ ├── Types.qs │ │ │ │ ├── Logging.qs │ │ │ │ ├── Library1.csproj │ │ │ │ └── AccessModifiers.qs │ │ │ └── Library2 │ │ │ │ ├── Library.qs │ │ │ │ └── Library2.csproj │ │ └── Simulation │ │ │ └── Example │ │ │ └── Main.qs │ ├── SyntaxProcessor │ │ └── CapabilityInference │ │ │ ├── ConstAnalyzer.fsi │ │ │ ├── TypeAnalyzer.fsi │ │ │ ├── FeatureAnalyzer.fsi │ │ │ └── ResultAnalyzer.fsi │ ├── QirGeneration │ │ ├── QirGeneration.props │ │ └── QirGeneration.csproj │ ├── LlvmBindings │ │ ├── cgmanifest.json │ │ ├── stylecop.json │ │ ├── Extensions │ │ │ ├── StringExtensions.cs │ │ │ ├── LLVMMCJITCompilerOptionsExtensions.cs │ │ │ └── LLVMMemoryBufferRefExtensions.cs │ │ ├── Interop │ │ │ └── LLVMAttributeIndex.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Instructions │ │ │ ├── Trunc.cs │ │ │ ├── SignExtend.cs │ │ │ ├── MemMove.cs │ │ │ ├── UIToFP.cs │ │ │ ├── ZeroExtend.cs │ │ │ ├── MemSet.cs │ │ │ ├── BitCast.cs │ │ │ ├── MemCpy.cs │ │ │ ├── ReturnInstruction.cs │ │ │ ├── SelectInstruction.cs │ │ │ ├── Terminator.cs │ │ │ ├── UnaryOperator.cs │ │ │ ├── BinaryOperator.cs │ │ │ ├── MemIntrinsic.cs │ │ │ ├── PointerToInt.cs │ │ │ ├── Unreachable.cs │ │ │ ├── SIToFP.cs │ │ │ ├── ShuffleVector.cs │ │ │ ├── UnaryInstruction.cs │ │ │ ├── VAArg.cs │ │ │ ├── UserOp2.cs │ │ │ ├── DebugInfoIntrinsic.cs │ │ │ ├── UserOp1.cs │ │ │ ├── IntCmp.cs │ │ │ ├── FCmp.cs │ │ │ ├── AddressSpaceCast.cs │ │ │ ├── FPExt.cs │ │ │ └── FPToUI.cs │ │ ├── Values │ │ │ ├── ConstantData.cs │ │ │ ├── ConstantDataArray.cs │ │ │ └── ConstantAggregate.cs │ │ ├── DebugInfo │ │ │ ├── DINode.cs │ │ │ ├── DILexicalBlockBase.cs │ │ │ ├── DIMacroNode.cs │ │ │ ├── DIExpression.cs │ │ │ └── DILexicalBlock.cs │ │ └── Metadata │ │ │ ├── ValueAsMetadata.cs │ │ │ ├── ConstantAsMetadata.cs │ │ │ └── MDTuple.cs │ ├── Tests.LanguageServer │ │ └── MsBuildDefaultsRegistration.cs │ ├── CommandLineTool │ │ └── App.config │ └── CompilationManager │ │ └── FileContentException.cs ├── VisualStudioExtension │ ├── QSharpVsix │ │ ├── tags.txt │ │ ├── MS_Quantum_Spot_Dev-32.png │ │ ├── MS_Quantum_Spot_Dev-1024.png │ │ ├── MS_Quantum_Spot_Dev-200.png │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── syntax.pkgdef │ ├── .gitignore │ ├── QSharpAppTemplate │ │ ├── MS_Quantum_Spot_Dev-32.png │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── AppProjectTemplate.xml.v.template │ │ └── Program.qs │ ├── QSharpFileTemplate │ │ ├── MS_Quantum_Spot_Dev-32.png │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── Operation.qs │ ├── QSharpLibTemplate │ │ ├── MS_Quantum_Spot_Dev-32.png │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── LibProjectTemplate.xml.v.template │ │ └── Library.qs │ ├── QSharpTestTemplate │ │ ├── MS_Quantum_Spot_Dev-32.png │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Tests.qs │ │ └── TestProjectTemplate.xml.v.template │ ├── QsharpIonQAppTemplate │ │ ├── MS_Quantum_Spot_Dev-32.png │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── IonQAppProjectTemplate.xml.v.template │ │ └── Program.qs │ └── QsharpQuantinuumAppTemplate │ │ ├── MS_Quantum_Spot_Dev-32.png │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ ├── Program.qs │ │ └── QuantinuumAppProjectTemplate.xml.v.template ├── QsFmt │ ├── App.Tests │ │ └── Examples │ │ │ ├── SyntaxError.qs │ │ │ ├── Example1.qs │ │ │ ├── Example2.qs │ │ │ ├── TestTarget │ │ │ ├── Excluded1.qs │ │ │ ├── Excluded2.qs │ │ │ ├── Included.qs │ │ │ ├── Program.qs │ │ │ └── TestTarget.csproj │ │ │ ├── SubExamples1 │ │ │ ├── SubExample1.qs │ │ │ └── SubExample2.qs │ │ │ ├── SubExamples2 │ │ │ ├── SubExample3.qs │ │ │ └── NestedExamples │ │ │ │ ├── NestedExample1.qs │ │ │ │ └── NestedExample2.qs │ │ │ └── TestProjects │ │ │ ├── SimpleLibrary │ │ │ ├── Excluded1.qs │ │ │ ├── Included1.qs │ │ │ ├── SubFolder1 │ │ │ │ ├── Excluded2.qs │ │ │ │ ├── Included2.qs │ │ │ │ └── SubSubFolder │ │ │ │ │ ├── Excluded4.qs │ │ │ │ │ └── Included4.qs │ │ │ ├── SubFolder2 │ │ │ │ ├── Excluded3.qs │ │ │ │ └── Included3.qs │ │ │ └── Library.qs │ │ │ ├── SimpleApplication │ │ │ ├── Excluded1.qs │ │ │ ├── Included1.qs │ │ │ ├── SubFolder1 │ │ │ │ ├── Excluded2.qs │ │ │ │ ├── Included2.qs │ │ │ │ └── SubSubFolder │ │ │ │ │ ├── Excluded4.qs │ │ │ │ │ └── Included4.qs │ │ │ ├── SubFolder2 │ │ │ │ ├── Excluded3.qs │ │ │ │ └── Included3.qs │ │ │ └── Program.qs │ │ │ ├── SimpleTestProject │ │ │ ├── Excluded1.qs │ │ │ ├── Included1.qs │ │ │ ├── SubFolder1 │ │ │ │ ├── Excluded2.qs │ │ │ │ ├── Included2.qs │ │ │ │ └── SubSubFolder │ │ │ │ │ ├── Excluded4.qs │ │ │ │ │ └── Included4.qs │ │ │ ├── SubFolder2 │ │ │ │ ├── Excluded3.qs │ │ │ │ └── Included3.qs │ │ │ └── Tests.qs │ │ │ ├── OldApplication │ │ │ ├── Operation.qs │ │ │ ├── Driver.cs │ │ │ └── OldApplication.csproj │ │ │ ├── ReferenceLibrary │ │ │ ├── ReferenceLibrary.csproj │ │ │ └── Library.qs │ │ │ └── OldVersion │ │ │ ├── OldVersion.csproj │ │ │ └── Program.qs │ ├── App │ │ ├── AssemblyInfo.fs │ │ ├── Program.fsi │ │ └── DesignTimeBuild.fsi │ ├── Parser │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ ├── Formatter │ │ ├── Utils.fs │ │ ├── Printer.fsi │ │ ├── Utils.fsi │ │ ├── Errors.fsi │ │ └── ParseTree │ │ │ └── Namespace.fsi │ ├── .vscode │ │ ├── launch.json │ │ └── tasks.json │ └── Formatter.Tests │ │ └── Errors.fs ├── VSCodeExtension │ ├── templates │ │ ├── ionq │ │ │ ├── .gitignore │ │ │ ├── IonQApplication.csproj.v.template │ │ │ └── Program.qs │ │ ├── library │ │ │ ├── .gitignore │ │ │ ├── Library.csproj.v.template │ │ │ └── Library.qs │ │ ├── application │ │ │ ├── .gitignore │ │ │ ├── Application.csproj.v.template │ │ │ └── Program.qs │ │ ├── quantinuum │ │ │ ├── .gitignore │ │ │ ├── Program.qs │ │ │ └── QuantinuumApplication.csproj.v.template │ │ └── unittest │ │ │ ├── .gitignore │ │ │ ├── Tests.qs │ │ │ └── Test.csproj.v.template │ ├── test │ │ ├── Run.ps1 │ │ └── README.md │ ├── MS_Quantum_Spot_Dev-200.png │ ├── .gitignore │ ├── .vscode │ │ ├── extensions.json │ │ ├── settings.json │ │ └── tasks.json │ ├── .vscodeignore │ ├── tslint.json │ ├── snippets │ │ └── csharp.json │ ├── README.md │ ├── language-configuration.json │ └── src │ │ ├── decompress-zip.d.ts │ │ └── sanitize-namespace-name.ts ├── Documentation │ ├── Summarizer │ │ ├── requirements.txt │ │ └── README.md │ ├── DocumentationGenerator │ │ └── DocumentationGenerator.props │ └── Tests.DocGenerator │ │ └── Utils.cs ├── Telemetry │ ├── Build │ │ ├── Test.ps1 │ │ ├── Build.ps1 │ │ └── test-coverage.ps1 │ ├── Library │ │ ├── Commands │ │ │ ├── CommandType.cs │ │ │ ├── ICommandProcessor.cs │ │ │ ├── IOutOfProcessSerializer.cs │ │ │ ├── CommandBase.cs │ │ │ └── QuitCommand.cs │ │ ├── DataContracts │ │ │ ├── TelemetryPropertyType.cs │ │ │ ├── SerializeJsonAttribute.cs │ │ │ ├── TelemetryExceptionRecord.cs │ │ │ └── PiiDataAttribute.cs │ │ └── TelemetryManagerConstants.cs │ ├── Samples │ │ └── CSharp │ │ │ └── CSharp.csproj │ └── Tests.OutOfProcessExe │ │ └── OutOfProcessExe.csproj ├── ProjectTemplates │ ├── Quantum.Library1 │ │ ├── Quantum.Library1.csproj.v.template │ │ ├── Library.qs │ │ └── .template.config │ │ │ └── template.json.v.template │ ├── Quantum.App1 │ │ ├── Quantum.App1.csproj.v.template │ │ ├── Program.qs │ │ └── .template.config │ │ │ └── template.json.v.template │ ├── Quantum.IonQ.App1 │ │ ├── Program.qs │ │ ├── Quantum.IonQ.App1.csproj.v.template │ │ └── .template.config │ │ │ └── template.json.v.template │ ├── Quantum.Honeywell.App1 │ │ ├── Program.qs │ │ ├── Quantum.Honeywell.App1.csproj.v.template │ │ └── .template.config │ │ │ └── template.json.v.template │ ├── Quantum.Quantinuum.App1 │ │ ├── Program.qs │ │ ├── Quantum.Quantinuum.App1.csproj.v.template │ │ └── .template.config │ │ │ └── template.json.v.template │ ├── Quantum.Test1 │ │ ├── Tests.qs │ │ ├── .template.config │ │ │ └── template.json.v.template │ │ └── Quantum.Test1.csproj.v.template │ └── README.md ├── QuantumSdk │ ├── Tools │ │ ├── Common │ │ │ └── DelaySign.cs │ │ ├── DefaultEntryPoint │ │ │ └── DefaultEntryPoint.csproj │ │ └── BuildConfiguration │ │ │ ├── BuildConfiguration.csproj │ │ │ └── Program.cs │ └── ProjectSystem │ │ ├── Rules │ │ └── ProjectItemsSchema.xaml │ │ └── ProjectSystem.props ├── Directory.Build.props └── Common │ ├── stylecop.json │ └── AssemblyCommon.cs.v.template ├── .sscignore ├── .devcontainer ├── Dockerfile └── devcontainer.json ├── global.json ├── .gitmodules ├── examples ├── QIR │ ├── Optimization │ │ └── Hello │ │ │ ├── Main.cpp │ │ │ └── Program.qs │ ├── JITCompilation │ │ ├── QIRinit.cpp │ │ └── Hello.ll │ ├── Simulation │ │ └── StateSimulator │ │ │ └── include │ │ │ └── Eigen │ │ │ └── README.md │ ├── Development │ │ └── Program.qs │ └── Emission │ │ └── README.md └── CompilerExtensions │ ├── Demo │ ├── Program.qs │ └── Demo.csproj │ ├── CustomExtension │ └── CustomExtension.csproj │ └── ExtensionPackage │ ├── CustomExtension.Package.csproj │ └── CompilerExtension.props ├── .vscode └── extensions.json ├── omnisharp.json ├── .config └── dotnet-tools.json ├── .gitattributes └── .github ├── ISSUE_TEMPLATE └── feature_request.md └── workflows ├── devskim.yml └── qdk-sync.yml /llvm-build/llvm.tag.txt: -------------------------------------------------------------------------------- 1 | llvmorg-14.0.6 -------------------------------------------------------------------------------- /src/QsCompiler/.gitignore: -------------------------------------------------------------------------------- 1 | Compiler.nuspec -------------------------------------------------------------------------------- /.sscignore: -------------------------------------------------------------------------------- 1 | { 2 | "cfs": ["CFS0012", "CFS0013"] 3 | } 4 | -------------------------------------------------------------------------------- /src/QsCompiler/CSharpGeneration/.gitignore: -------------------------------------------------------------------------------- 1 | CSharpGeneration.nuspec 2 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test12/README.md: -------------------------------------------------------------------------------- 1 | This is a valid Q# library app. -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpVsix/tags.txt: -------------------------------------------------------------------------------- 1 | Q# 2 | quantum 3 | qsharp 4 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/SyntaxError.qs: -------------------------------------------------------------------------------- 1 | namespace Foo { invalid syntax; } 2 | -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/ionq/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated or copied files 2 | *.csproj 3 | -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/library/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated or copied files 2 | *.csproj 3 | -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/application/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated or copied files 2 | *.csproj 3 | -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/quantinuum/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated or copied files 2 | *.csproj 3 | -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/unittest/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated or copied files 2 | *.csproj 3 | -------------------------------------------------------------------------------- /src/VSCodeExtension/test/Run.ps1: -------------------------------------------------------------------------------- 1 | tsc test.ts --outDir ../out/test 2 | mocha ../out/test/test 3 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test14/README.md: -------------------------------------------------------------------------------- 1 | This is a valid Q# app specifying an execution target. 2 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test17/README.md: -------------------------------------------------------------------------------- 1 | This is a valid Q# app specifying an execution target. 2 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test15/README.md: -------------------------------------------------------------------------------- 1 | This is a valid Q# app using the formatter source code. 2 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.RoslynWrapper/Program.fs: -------------------------------------------------------------------------------- 1 | module Program = 2 | [] 3 | let main _ = 0 4 | -------------------------------------------------------------------------------- /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/vscode/devcontainers/universal:1-linux 2 | 3 | USER codespace 4 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/README.md: -------------------------------------------------------------------------------- 1 | This folder contains projects used to test the LanguageServer's ProjectLoader. -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/Example1.qs: -------------------------------------------------------------------------------- 1 | namespace Example1 { function Bar() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/Example2.qs: -------------------------------------------------------------------------------- 1 | namespace Example2 { function Bar() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/.gitignore: -------------------------------------------------------------------------------- 1 | # Files generated using .v.template 2 | QSharpVsix/source.extension.vsixmanifest 3 | -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "6.0.302", 4 | "rollForward": "latestPatch" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestTarget/Excluded1.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Bar2() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestTarget/Excluded2.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Bar3() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestTarget/Included.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Bar1() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/SubExamples1/SubExample1.qs: -------------------------------------------------------------------------------- 1 | namespace SubExample1 { function Bar() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/SubExamples1/SubExample2.qs: -------------------------------------------------------------------------------- 1 | namespace SubExample2 { function Bar() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/SubExamples2/SubExample3.qs: -------------------------------------------------------------------------------- 1 | namespace SubExample3 { function Bar() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestTarget/Program.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { @EntryPoint() operation Bar() : Unit { for (i in 0..1) {} } } 2 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test2/Class1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace test2 4 | { 5 | public class Class1 6 | { 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "qsharp-language"] 2 | path = qsharp-language 3 | url = https://github.com/microsoft/qsharp-language.git 4 | branch = main 5 | -------------------------------------------------------------------------------- /src/Documentation/Summarizer/requirements.txt: -------------------------------------------------------------------------------- 1 | python-frontmatter 2 | click 3 | ruamel-yaml 4 | pyyaml>=5.4 # This version resolves CVE-2020-14343 5 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleLibrary/Excluded1.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Excluded1() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleLibrary/Included1.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Included1() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/VSCodeExtension/MS_Quantum_Spot_Dev-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/qsharp-compiler/HEAD/src/VSCodeExtension/MS_Quantum_Spot_Dev-200.png -------------------------------------------------------------------------------- /src/QsCompiler/LanguageServer/global.language-server.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "6.0.302", 4 | "rollForward": "latestPatch" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/SubExamples2/NestedExamples/NestedExample1.qs: -------------------------------------------------------------------------------- 1 | namespace NestedExample1 { function Bar() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/SubExamples2/NestedExamples/NestedExample2.qs: -------------------------------------------------------------------------------- 1 | namespace NestedExample2 { function Bar() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleApplication/Excluded1.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Excluded1() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleApplication/Included1.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Included1() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleTestProject/Excluded1.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Excluded1() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleTestProject/Included1.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Included1() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsCompiler/LanguageServer/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | dotnet_diagnostic.VSTHRD002.severity = none # Synchronously waiting on tasks or awaiters may cause deadlocks. 3 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleLibrary/SubFolder1/Excluded2.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Excluded2() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleLibrary/SubFolder1/Included2.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Included2() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleLibrary/SubFolder2/Excluded3.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Excluded3() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleLibrary/SubFolder2/Included3.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Included3() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /examples/QIR/Optimization/Hello/Main.cpp: -------------------------------------------------------------------------------- 1 | extern "C" void Hello__HelloQ(); 2 | 3 | int main(int argc, char* argv[]){ 4 | Hello__HelloQ(); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleApplication/SubFolder1/Excluded2.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Excluded2() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleApplication/SubFolder1/Included2.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Included2() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleApplication/SubFolder2/Excluded3.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Excluded3() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleApplication/SubFolder2/Included3.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Included3() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleTestProject/SubFolder1/Excluded2.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Excluded2() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleTestProject/SubFolder1/Included2.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Included2() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleTestProject/SubFolder2/Excluded3.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Excluded3() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleTestProject/SubFolder2/Included3.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Included3() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleLibrary/SubFolder1/SubSubFolder/Excluded4.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Excluded4() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleLibrary/SubFolder1/SubSubFolder/Included4.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Included4() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "editorconfig.editorconfig", 4 | "ionide.ionide-fsharp", 5 | "ms-dotnettools.csharp" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestDeclarations3.ll: -------------------------------------------------------------------------------- 1 | define internal void @Microsoft__Quantum__Testing__QIR__SelfAdjointOp__body() { 2 | entry: 3 | ret void 4 | } 5 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleApplication/SubFolder1/SubSubFolder/Excluded4.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Excluded4() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleApplication/SubFolder1/SubSubFolder/Included4.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Included4() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleTestProject/SubFolder1/SubSubFolder/Excluded4.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Excluded4() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleTestProject/SubFolder1/SubSubFolder/Included4.qs: -------------------------------------------------------------------------------- 1 | namespace TestTarget { function Included4() : Int { for (i in 0..1) {} return 0; } } 2 | -------------------------------------------------------------------------------- /src/QsFmt/App/AssemblyInfo.fs: -------------------------------------------------------------------------------- 1 | module AssemblyInfo 2 | 3 | open System.Runtime.CompilerServices 4 | 5 | [] 6 | do () 7 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpVsix/MS_Quantum_Spot_Dev-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/qsharp-compiler/HEAD/src/VisualStudioExtension/QSharpVsix/MS_Quantum_Spot_Dev-32.png -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test11/README.md: -------------------------------------------------------------------------------- 1 | This is a valid Q# console app with dependencies on test3. 2 | However, it is a 0.2* project and hence won't be picked up by the lanugage server. -------------------------------------------------------------------------------- /src/QsFmt/Parser/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | 6 | [assembly: CLSCompliant(true)] 7 | -------------------------------------------------------------------------------- /src/Telemetry/Build/Test.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | Push-Location $PSScriptRoot/../ 5 | 6 | dotnet test 7 | 8 | Pop-Location 9 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpVsix/MS_Quantum_Spot_Dev-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/qsharp-compiler/HEAD/src/VisualStudioExtension/QSharpVsix/MS_Quantum_Spot_Dev-1024.png -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpVsix/MS_Quantum_Spot_Dev-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/qsharp-compiler/HEAD/src/VisualStudioExtension/QSharpVsix/MS_Quantum_Spot_Dev-200.png -------------------------------------------------------------------------------- /src/Telemetry/Build/Build.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | Push-Location $PSScriptRoot/../ 5 | 6 | dotnet build 7 | 8 | Pop-Location 9 | -------------------------------------------------------------------------------- /src/VSCodeExtension/.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | bin 3 | node_modules 4 | .vscode-test/ 5 | *.vsix 6 | 7 | # Generated or copied files 8 | NOTICE.txt 9 | package.json 10 | package-lock.json 11 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpAppTemplate/MS_Quantum_Spot_Dev-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/qsharp-compiler/HEAD/src/VisualStudioExtension/QSharpAppTemplate/MS_Quantum_Spot_Dev-32.png -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpFileTemplate/MS_Quantum_Spot_Dev-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/qsharp-compiler/HEAD/src/VisualStudioExtension/QSharpFileTemplate/MS_Quantum_Spot_Dev-32.png -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpLibTemplate/MS_Quantum_Spot_Dev-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/qsharp-compiler/HEAD/src/VisualStudioExtension/QSharpLibTemplate/MS_Quantum_Spot_Dev-32.png -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpTestTemplate/MS_Quantum_Spot_Dev-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/qsharp-compiler/HEAD/src/VisualStudioExtension/QSharpTestTemplate/MS_Quantum_Spot_Dev-32.png -------------------------------------------------------------------------------- /src/VisualStudioExtension/QsharpIonQAppTemplate/MS_Quantum_Spot_Dev-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/qsharp-compiler/HEAD/src/VisualStudioExtension/QsharpIonQAppTemplate/MS_Quantum_Spot_Dev-32.png -------------------------------------------------------------------------------- /src/QsCompiler/RoslynWrapper/README.txt: -------------------------------------------------------------------------------- 1 | 2 | This project was originally copied from https://github.com/johnazariah/roslyn-wrapper 3 | It has been modified with changes specific for the Quantum Development Kit. 4 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.RoslynWrapper/README.txt: -------------------------------------------------------------------------------- 1 | 2 | This project was originally copied from https://github.com/johnazariah/roslyn-wrapper 3 | It has been modified with changes specific for the Quantum Development Kit. 4 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QsharpQuantinuumAppTemplate/MS_Quantum_Spot_Dev-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/qsharp-compiler/HEAD/src/VisualStudioExtension/QsharpQuantinuumAppTemplate/MS_Quantum_Spot_Dev-32.png -------------------------------------------------------------------------------- /src/QsCompiler/Tests.CSharpGeneration/Program.fs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | module Program = 5 | [] 6 | let main _ = 0 7 | -------------------------------------------------------------------------------- /src/VSCodeExtension/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "eg2.tslint" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpFileTemplate/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("Microsoft.Quantum.QSharpFileTemplate")] 4 | [assembly: AssemblyDescription("Q# file template")] 5 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpLibTemplate/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("Microsoft.Quantum.QSharpLibTemplate")] 4 | [assembly: AssemblyDescription("Q# library template")] 5 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpAppTemplate/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("Microsoft.Quantum.QSharpAppTemplate")] 4 | [assembly: AssemblyDescription("Q# application template")] 5 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/OldApplication/Operation.qs: -------------------------------------------------------------------------------- 1 | namespace OldApplication { 2 | open Microsoft.Quantum.Canon; 3 | open Microsoft.Quantum.Intrinsic; 4 | 5 | operation Operation () : Unit { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/library/Library.csproj.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpTestTemplate/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("Microsoft.Quantum.QSharpTestTemplate")] 4 | [assembly: AssemblyDescription("Q# test project template")] 5 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestGenerics1.ll: -------------------------------------------------------------------------------- 1 | define internal void @Microsoft__Quantum__Testing__QIR__DumpMachineTest__body() { 2 | entry: 3 | call void @__quantum__qis__dumpmachine__body(i8* null) 4 | ret void 5 | } 6 | -------------------------------------------------------------------------------- /src/QsFmt/Formatter/Utils.fs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | module Microsoft.Quantum.QsFmt.Formatter.Utils 5 | 6 | let curry f x y = f (x, y) 7 | 8 | let curry3 f x y z = f (x, y, z) 9 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QsharpIonQAppTemplate/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("Microsoft.Quantum.IonQ.QSharpAppTemplate")] 4 | [assembly: AssemblyDescription("Q# application template")] 5 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.Library1/Quantum.Library1.csproj.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test16/test16.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Exe 4 | netcoreapp3.1 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test2/test2.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | x64 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestDeclarations4.ll: -------------------------------------------------------------------------------- 1 | define internal void @Microsoft__Quantum__Testing__QIR__SelfAdjointOp__adj() { 2 | entry: 3 | call void @Microsoft__Quantum__Testing__QIR__SelfAdjointOp__body() 4 | ret void 5 | } 6 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/ReferenceLibrary/ReferenceLibrary.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpLibTemplate/LibProjectTemplate.xml.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QsharpQuantinuumAppTemplate/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("Microsoft.Quantum.Quantinuum.QSharpAppTemplate")] 4 | [assembly: AssemblyDescription("Q# application template")] 5 | -------------------------------------------------------------------------------- /omnisharp.json: -------------------------------------------------------------------------------- 1 | { 2 | "FormattingOptions": { 3 | "enableEditorConfigSupport": true 4 | }, 5 | "RoslynExtensionsOptions": { 6 | "enableAnalyzersSupport": true, 7 | "enableDecompilationSupport": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test10/test10.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test11/test11.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/VSCodeExtension/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | out/test/** 4 | out/**/*.map 5 | src/** 6 | **/.gitignore 7 | tsconfig.json 8 | vsc-extension-quickstart.md 9 | tslint.json 10 | Build-Dependencies.ps1 11 | BUILDING.md 12 | **/*.v.template 13 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpFileTemplate/Operation.qs: -------------------------------------------------------------------------------- 1 | namespace $rootnamespace$ { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | 7 | operation $safeitemname$ () : Unit { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/Core/Utils.fs: -------------------------------------------------------------------------------- 1 | module Microsoft.Quantum.QsCompiler.Utils 2 | 3 | /// Converts a C# Try-style return value into an F# option. 4 | [] 5 | let tryOption = 6 | function 7 | | true, value -> Some value 8 | | false, _ -> None 9 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test1/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace test1 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Console.WriteLine("Hello World!"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test8/Class1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace test8 8 | { 9 | public class Class1 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/library/Library.qs: -------------------------------------------------------------------------------- 1 | namespace <%= name %> { 2 | open Microsoft.Quantum.Canon; 3 | open Microsoft.Quantum.Intrinsic; 4 | 5 | 6 | operation SayHello() : Unit { 7 | Message("Hello quantum world!"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.App1/Quantum.App1.csproj.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/QIR/Optimization/Hello/Program.qs: -------------------------------------------------------------------------------- 1 | namespace Hello { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | @EntryPoint() 7 | operation HelloQ() : Unit { 8 | Message("Hello quantum world!"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestTargets/Libraries/build/Library.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | x64 4 | 0.11 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestLibraryGeneration1.ll: -------------------------------------------------------------------------------- 1 | define void @Microsoft__Quantum__Testing__QIR__Baz__body(%Qubit* %q) { 2 | entry: 3 | call void @__quantum__qis__h__body(%Qubit* %q) 4 | call void @__quantum__qis__t__body(%Qubit* %q) 5 | ret void 6 | } 7 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestLibraryGeneration2.ll: -------------------------------------------------------------------------------- 1 | define void @Microsoft__Quantum__Testing__QIR__Baz__adj(%Qubit* %q) { 2 | entry: 3 | call void @__quantum__qis__t__adj(%Qubit* %q) 4 | call void @__quantum__qis__h__body(%Qubit* %q) 5 | ret void 6 | } 7 | -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/application/Application.csproj.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.Library1/Library.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.Library1 { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | 7 | operation HelloQ () : Unit { 8 | Message("Hello quantum world!"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/OldVersion/OldVersion.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpAppTemplate/AppProjectTemplate.xml.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test1/test1.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | x64 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test11/Driver.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Quantum.Simulation.Core; 2 | using Microsoft.Quantum.Simulation.Simulators; 3 | 4 | namespace test3 5 | { 6 | class Driver 7 | { 8 | static void Main(string[] args) 9 | { 10 | 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test13/Driver.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Quantum.Simulation.Core; 2 | using Microsoft.Quantum.Simulation.Simulators; 3 | 4 | namespace test3 5 | { 6 | class Driver 7 | { 8 | static void Main(string[] args) 9 | { 10 | 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test4/Driver.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Quantum.Simulation.Core; 2 | using Microsoft.Quantum.Simulation.Simulators; 3 | 4 | namespace test3 5 | { 6 | class Driver 7 | { 8 | static void Main(string[] args) 9 | { 10 | 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test9/Driver.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Quantum.Simulation.Core; 2 | using Microsoft.Quantum.Simulation.Simulators; 3 | 4 | namespace test3 5 | { 6 | class Driver 7 | { 8 | static void Main(string[] args) 9 | { 10 | 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/ResultComparison.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.Test { 2 | @EntryPoint() 3 | operation HelloQ () : Result { 4 | mutable a = 0; 5 | if (One == One) { 6 | set a = 1; 7 | } 8 | return Zero; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/application/Program.qs: -------------------------------------------------------------------------------- 1 | namespace <%= name %> { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | @EntryPoint() 7 | operation SayHello() : Unit { 8 | Message("Hello quantum world!"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpLibTemplate/Library.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.$safeprojectname$ { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | 7 | operation HelloQ () : Unit { 8 | Message("Hello quantum world!"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.App1/Program.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.App1 { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | 7 | @EntryPoint() 8 | operation HelloQ() : Unit { 9 | Message("Hello quantum world!"); 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/QsCompiler/Core/SymbolTable/SymbolNotFoundException.fs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.QsCompiler.SymbolManagement 2 | 3 | open System 4 | 5 | /// An exception that is thrown when a symbol could not be found in the symbol table. 6 | type SymbolNotFoundException(message) = 7 | inherit Exception(message) 8 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestGenerics2.ll: -------------------------------------------------------------------------------- 1 | define internal void @Microsoft__Quantum__Testing__QIR__DumpMachineToFileTest__body(%String* %filePath) { 2 | entry: 3 | %0 = bitcast %String* %filePath to i8* 4 | call void @__quantum__qis__dumpmachine__body(i8* %0) 5 | ret void 6 | } 7 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpVsix/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | 4 | [assembly: AssemblyTitle("Microsoft.Quantum.QSharpVsix")] 5 | [assembly: AssemblyDescription("Microsoft Quantum Development Kit")] 6 | [assembly: NeutralResourcesLanguage("en-US")] 7 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test14/test14.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | ionq.qpu 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test17/test17.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | qci.qpu 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/QsFmt/App/Program.fsi: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | /// The command-line interface for the Q# formatter. 5 | module Microsoft.Quantum.QsFmt.App.Program 6 | 7 | /// Runs the Q# formatter. 8 | [] 9 | val main: string [] -> int 10 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.CSharpGeneration/Circuits/Types.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum { 5 | 6 | newtype Pair = (Fst : Int, Snd : Int); 7 | newtype NestedPair = (Double, ((Fst : Bool, String), Snd : Int)); 8 | } -------------------------------------------------------------------------------- /src/Telemetry/Library/Commands/CommandType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Telemetry.Commands 5 | { 6 | public enum CommandType 7 | { 8 | SetContext, 9 | LogEvent, 10 | Quit, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpAppTemplate/Program.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.$safeprojectname$ { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | 7 | @EntryPoint() 8 | operation HelloQ () : Unit { 9 | Message("Hello quantum world!"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test10/Operation10.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test3 { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test11/Operation11.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test3 { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test13/Operation13.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test3 { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test3/Operation3a.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test3 { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation3a () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test3/Operation3b.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test3 { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation3b () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test4/Operation4.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test3 { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test5/Operation5.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test5 { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation5 () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test6/Operation6a.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test6 { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation6a () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test9/Operation9.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test3 { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test12/Operation12a.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test3 { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation12a () : () { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test12/Operation12b.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test3 { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation12b () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test7/Operation.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test7 5 | { 6 | open Microsoft.Quantum.Canon; 7 | open Microsoft.Quantum.Intrinsic; 8 | 9 | operation Operation () : Unit { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.CSharpGeneration/Circuits/Core.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Core { 5 | @Attribute() 6 | newtype Attribute = Unit; 7 | 8 | @Attribute() 9 | newtype EntryPoint = Unit; 10 | } 11 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/OldVersion/Program.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.QSharpApplication1 { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | 7 | @EntryPoint() 8 | operation HelloQ () : Unit { 9 | Message("Hello quantum world!"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/CompilerExtensions/Demo/Program.qs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.Demo { 2 | 3 | function GetPair (n : Int) : (Int, Int) { 4 | return (n, n+1); 5 | } 6 | 7 | @EntryPoint() 8 | operation SampleProgram () : Int { 9 | let (a, b) = GetPair(5); 10 | return a + b; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test12/format/Unformatted.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Tests { 5 | 6 | operation Test() : () { 7 | let arr = new Int[10]; 8 | for (i in 1 .. 10) { 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test12/test12.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test3/sub1/Operation3b.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test3.sub1{ 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation3b () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestTargets/Libraries/Library1/Types.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing{ 5 | 6 | /// # Summary 7 | /// Contains a complex number. 8 | newtype Complex = (Re : Double, Im : Double); 9 | } 10 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/OldApplication/Driver.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Quantum.Simulation.Core; 2 | using Microsoft.Quantum.Simulation.Simulators; 3 | 4 | namespace OldApplication 5 | { 6 | class Driver 7 | { 8 | static void Main(string[] args) 9 | { 10 | 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/ReferenceLibrary/Library.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.ReferenceLibrary { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | 7 | operation LibraryOperation () : Unit { 8 | Message("Hello from the Reference Library!"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.IonQ.App1/Program.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.App1 { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | @EntryPoint() 7 | operation GetRandomResult() : Result { 8 | use q = Qubit(); 9 | H(q); 10 | return M(q); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/QsCompiler/Core/AssemblyInfo.fs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace QsCompiler.AssemblyInfo 5 | 6 | open System.Runtime.CompilerServices 7 | 8 | [] 9 | 10 | do () 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test12/sub1/Operation12b.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test3.sub1{ 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation3b () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test6/sub1/Operation6a.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test6.sub1 5 | { 6 | open Microsoft.Quantum.Canon; 7 | open Microsoft.Quantum.Intrinsic; 8 | 9 | operation Operation6a () : Unit { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/ionq/IonQApplication.csproj.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | ionq.qpu 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.Honeywell.App1/Program.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.App1 { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | @EntryPoint() 7 | operation GetRandomResult() : Result { 8 | use q = Qubit(); 9 | H(q); 10 | return M(q); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.IonQ.App1/Quantum.IonQ.App1.csproj.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | ionq.qpu 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test12/format/Formatted.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Tests { 5 | 6 | operation Test() : Unit { 7 | let arr = [0, size = 10]; 8 | for i in 1 .. 10 { 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test3/sub1/sub2/Operation3a.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test3.sub1.sub2 { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation3a () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/ionq/Program.qs: -------------------------------------------------------------------------------- 1 | namespace <%= name %> { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | @EntryPoint() 7 | operation GetRandomResult() : Result { 8 | use q = Qubit(); 9 | H(q); 10 | return M(q); 11 | } 12 | } 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/VSCodeExtension/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-string-throw": true, 4 | "no-unused-expression": true, 5 | "no-duplicate-variable": true, 6 | "curly": true, 7 | "class-name": true, 8 | "semicolon": [ 9 | true, 10 | "always" 11 | ], 12 | "triple-equals": true 13 | }, 14 | "defaultSeverity": "warning" 15 | } -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.Quantinuum.App1/Program.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.App1 { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | @EntryPoint() 7 | operation GetRandomResult() : Result { 8 | use q = Qubit(); 9 | H(q); 10 | return M(q); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test12/sub1/sub2/Operation12a.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test3.sub1.sub2 { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation3a () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test5/test.folder/Operation5.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test5.test.folder { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation Operation5 () : Unit { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/QuantumSdk/Tools/Common/DelaySign.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | #if SIGNED 5 | using System.Reflection; 6 | 7 | // Attributes for delay-signing 8 | [assembly: AssemblyKeyFile("..\\..\\..\\..\\build\\267DevDivSNKey2048.snk")] 9 | [assembly: AssemblyDelaySign(true)] 10 | #endif 11 | -------------------------------------------------------------------------------- /src/VSCodeExtension/snippets/csharp.json: -------------------------------------------------------------------------------- 1 | { 2 | "Using QuantumSimulator": { 3 | "prefix": "using", 4 | "body": [ 5 | "using (var ${1:qsim} = new QuantumSimulator())", 6 | "{", 7 | " var result = await ${2:Operation}.Run($1, ${3:args});", 8 | "}" 9 | ] 10 | } 11 | } -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/quantinuum/Program.qs: -------------------------------------------------------------------------------- 1 | namespace <%= name %> { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | @EntryPoint() 7 | operation GetRandomResult() : Result { 8 | use q = Qubit(); 9 | H(q); 10 | return M(q); 11 | } 12 | } 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test15/format/Unformatted.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Tests { 5 | 6 | @EntryPoint() 7 | operation Test() : () { 8 | let arr = new Int[10]; 9 | for (i in 1 .. 10) { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/QsFmt/Formatter/Printer.fsi: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | /// Syntax tree printing. 5 | module internal Microsoft.Quantum.QsFmt.Formatter.Printer 6 | 7 | open Microsoft.Quantum.QsFmt.Formatter.SyntaxTree 8 | 9 | /// Prints a syntax tree to a string. 10 | val printer: string Reducer 11 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QsharpIonQAppTemplate/IonQAppProjectTemplate.xml.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | ionq.qpu 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/CompilerExtensions/CustomExtension/CustomExtension.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /examples/CompilerExtensions/ExtensionPackage/CustomExtension.Package.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/quantinuum/QuantinuumApplication.csproj.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | quantinuum.qpu.h1 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.Honeywell.App1/Quantum.Honeywell.App1.csproj.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | quantinuum.qpu.h1 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.Quantinuum.App1/Quantum.Quantinuum.App1.csproj.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | quantinuum.qpu.h1 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QsharpIonQAppTemplate/Program.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.$safeprojectname$ { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | @EntryPoint() 7 | operation GetRandomResult() : Result { 8 | use q = Qubit(); 9 | H(q); 10 | return M(q); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test15/format/Formatted.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Tests { 5 | 6 | @EntryPoint() 7 | operation Test() : Unit { 8 | let arr = [0, size = 10]; 9 | for i in 1 .. 10 { 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QsharpQuantinuumAppTemplate/Program.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.$safeprojectname$ { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | @EntryPoint() 7 | operation GetRandomResult() : Result { 8 | use q = Qubit(); 9 | H(q); 10 | return M(q); 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QsharpQuantinuumAppTemplate/QuantinuumAppProjectTemplate.xml.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | quantinuum.qpu.h1 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "fantomas-tool": { 6 | "version": "4.7.9", 7 | "commands": [ 8 | "fantomas" 9 | ] 10 | }, 11 | "dotnet-fsharplint": { 12 | "version": "0.21.2", 13 | "commands": [ 14 | "dotnet-fsharplint" 15 | ] 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Documentation/Summarizer/README.md: -------------------------------------------------------------------------------- 1 | # summarize_documentation 2 | 3 | This utility summarizes Markdown documentation gathered from one or more compilation units, 4 | producing namespace and TOC files from the gathered documentation. 5 | 6 | For example: 7 | 8 | ```bash 9 | $ pip install -r requirements.txt 10 | $ python obj/qsharp/docs/*.md obj/qsharp/docs 11 | ``` 12 | -------------------------------------------------------------------------------- /src/QsCompiler/SyntaxProcessor/CapabilityInference/ConstAnalyzer.fsi: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | module internal Microsoft.Quantum.QsCompiler.SyntaxProcessing.CapabilityInference.ConstAnalyzer 5 | 6 | open Microsoft.Quantum.QsCompiler.Transformations.Core 7 | 8 | val analyzer: Analyzer unit> 9 | -------------------------------------------------------------------------------- /src/QsCompiler/SyntaxProcessor/CapabilityInference/TypeAnalyzer.fsi: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | module internal Microsoft.Quantum.QsCompiler.SyntaxProcessing.CapabilityInference.TypeAnalyzer 5 | 6 | open Microsoft.Quantum.QsCompiler.Transformations.Core 7 | 8 | val analyzer: Analyzer unit> 9 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/OptimizerTests/TypedParameters_output.txt: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.Arrays { 2 | 3 | function IndexRange<'T> (array : 'T[]) : Range { 4 | 5 | return 0 .. Length<'T>(array) - 1; 6 | } 7 | 8 | 9 | function Length<'T> (array : 'T[]) : Int { 10 | body intrinsic; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestUsing1.ll: -------------------------------------------------------------------------------- 1 | define internal void @Microsoft__Quantum__Testing__QIR__TestUsing__body() { 2 | entry: 3 | %q = call %Qubit* @__quantum__rt__qubit_allocate() 4 | call void @Microsoft__Quantum__Testing__QIR__ArbitraryAllocation__body(i64 3, %Qubit* %q) 5 | call void @__quantum__rt__qubit_release(%Qubit* %q) 6 | ret void 7 | } 8 | -------------------------------------------------------------------------------- /src/QsCompiler/SyntaxProcessor/CapabilityInference/FeatureAnalyzer.fsi: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | module internal Microsoft.Quantum.QsCompiler.SyntaxProcessing.CapabilityInference.FeatureAnalyzer 5 | 6 | open Microsoft.Quantum.QsCompiler.Transformations.Core 7 | 8 | val analyzer: Analyzer unit> 9 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Prevent GitHub from excluding the build/ directory from the file finder. 3 | # See: https://docs.github.com/en/search-github/searching-on-github/finding-files-on-github 4 | ############################################################################### 5 | build/** linguist-generated=false 6 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.CSharpGeneration/Circuits/HelloWorld.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Tests.Inline 5 | { 6 | 7 | operation HelloWorld (n : Int) : Int 8 | { 9 | let r = n + 1; 10 | 11 | return r; 12 | } 13 | 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.CSharpGeneration/Circuits/SubDirectory/HelloOther.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Tests.SubDirectory 5 | { 6 | 7 | operation HelloOther (n : Int) : Int 8 | { 9 | let r = n + 1; 10 | 11 | return r; 12 | } 13 | 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/VSCodeExtension/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "out": false // set this to true to hide the "out" folder with the compiled JS files 5 | }, 6 | "search.exclude": { 7 | "out": true // set this to false to include "out" folder in search results 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpVsix/syntax.pkgdef: -------------------------------------------------------------------------------- 1 | [$RootKey$\TextMate\Repositories] 2 | "QSharp"="$PackageFolder$\Grammars" 3 | 4 | [$RootKey$\InstalledProducts\MicrosoftQuantumDevelopmentKit] 5 | @="Microsoft Quantum Development Kit" 6 | "ProductDetails"="Microsoft Quantum Development Kit provides support for developing quantum algorithms in the Q# programming language." 7 | "PID"="0 and 1" 8 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "dockerFile": "./Dockerfile", 3 | "extensions": [ 4 | "ms-dotnettools.csharp", 5 | "Ionide.Ionide-fsharp", 6 | "ms-vscode.powershell", 7 | "quantum.quantum-devkit-vscode", 8 | "ms-vscode.cpptools" 9 | ], 10 | "settings": { 11 | "terminal.integrated.shell.linux": "/usr/bin/pwsh" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/QsCompiler/CSharpGeneration/RewriteStep.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $(MSBuildThisFileDirectory)/../lib/net6.0/Microsoft.Quantum.CSharpGeneration.dll 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/VSCodeExtension/test/README.md: -------------------------------------------------------------------------------- 1 | # Quantum VS Code Extension Unit Tests 2 | 3 | This folder contains Run.ps1, a script that will transpile and run the unit tests for the Quantum VS Code Extension. 4 | 5 | 6 | ## Running locally 7 | 8 | 1. Make this folder your current directory location: qsharp-compiler\src\VSCodeExtension\test 9 | 10 | 2. Execute [`.\Run.ps1`](.\Run.ps1) to run the tests. 11 | -------------------------------------------------------------------------------- /examples/QIR/JITCompilation/QIRinit.cpp: -------------------------------------------------------------------------------- 1 | #include "QirContext.hpp" 2 | #include "SimFactory.hpp" 3 | 4 | #include 5 | 6 | using namespace Microsoft::Quantum; 7 | 8 | extern "C" void InitQIRSim() 9 | { 10 | // initialize Quantum Simulator and QIR Runtime 11 | std::unique_ptr sim = CreateFullstateSimulator(); 12 | InitializeQirContext(sim.release(), true); 13 | } 14 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.CSharpGeneration/Circuits/SubDirectory/HelloWorld.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Tests.SubDirectory 5 | { 6 | 7 | operation HelloWorld (n : Int) : Int 8 | { 9 | let r = n + 1; 10 | 11 | return r; 12 | } 13 | 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestDeclarations5.ll: -------------------------------------------------------------------------------- 1 | define internal void @Microsoft__Quantum__Testing__QIR__SelfAdjointOp__ctl(%Array* %__controlQubits__, %Tuple* %__unitArg__) { 2 | entry: 3 | call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i32 1) 4 | call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i32 -1) 5 | ret void 6 | } 7 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.CSharpGeneration/Circuits/EmptyElements.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum 5 | { 6 | newtype Pair = (Int,Int); 7 | newtype Unused = (Int,Int); 8 | function emptyFunction (p:Pair) : Unit { body intrinsic; } 9 | operation emptyOperation () : Unit { body intrinsic; } 10 | } -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestTarget/TestTarget.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/OptimizerTests/Reordering_output.txt: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.Testing.Optimization.Reordering { 2 | 3 | operation f (n : Int) : Unit { 4 | body intrinsic; 5 | } 6 | 7 | 8 | operation Test (x : Int) : Unit { 9 | 10 | let y = x + 2; 11 | let z = y + 2; 12 | f(y); 13 | f(z); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /src/QsCompiler/QirGeneration/QirGeneration.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(MSBuildThisFileDirectory)/../lib/net6.0/Microsoft.Quantum.QirGeneration.dll 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/cgmanifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "Registrations": [ 3 | { 4 | "Component": { 5 | "Type": "git", 6 | "Git": { 7 | "RepositoryUrl": "https://github.com/UbiquityDotNET/Llvm.NET", 8 | "CommitHash": "40ef96d067f9dea0cfed05a224030669c1b3186a" 9 | } 10 | }, 11 | "DevelopmentDependency": [ false ] 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /src/QsFmt/Formatter/Utils.fsi: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | /// General utility functions. 5 | module internal Microsoft.Quantum.QsFmt.Formatter.Utils 6 | 7 | /// Curries a function of two arguments. 8 | val curry: ('a * 'b -> 'c) -> 'a -> 'b -> 'c 9 | 10 | /// Curries a function of three arguments. 11 | val curry3: ('a * 'b * 'c -> 'd) -> 'a -> 'b -> 'c -> 'd 12 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestPaulis.ll: -------------------------------------------------------------------------------- 1 | define internal i2 @Microsoft__Quantum__Testing__QIR__TestPaulis__body(i2 %a, i2 %b) { 2 | entry: 3 | %0 = icmp eq i2 %a, 1 4 | br i1 %0, label %then0__1, label %continue__1 5 | 6 | then0__1: ; preds = %entry 7 | ret i2 -1 8 | 9 | continue__1: ; preds = %entry 10 | ret i2 %b 11 | } 12 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestLibraryGeneration3.ll: -------------------------------------------------------------------------------- 1 | define i1 @Microsoft__Quantum__Testing__QIR__Foo__body(i64 %c1, i1 %c2) { 2 | entry: 3 | %0 = icmp sgt i64 %c1, 0 4 | %1 = and i1 %0, %c2 5 | %2 = call i1 @Microsoft__Quantum__Testing__QIR_____GUID___Bar__body(i1 %1) 6 | ret i1 %2 7 | } 8 | 9 | define internal i1 @Microsoft__Quantum__Testing__QIR_____GUID___Bar__body(i1 %a1) { 10 | entry: 11 | ret i1 %a1 12 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestPaulis.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | @EntryPoint() 7 | function TestPaulis (a : Pauli, b : Pauli) : Pauli 8 | { 9 | if (a == PauliX) 10 | { 11 | return PauliY; 12 | } 13 | return b; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Telemetry/Library/Commands/ICommandProcessor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Telemetry.Commands 5 | { 6 | public interface ICommandProcessor 7 | { 8 | void ProcessCommand(QuitCommand command); 9 | 10 | void ProcessCommand(LogEventCommand command); 11 | 12 | void ProcessCommand(SetContextCommand command); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/OptimizerTests/NoOp_output.txt: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.Testing.Optimization.NoOp { 2 | 3 | operation f (n : Int) : Unit { 4 | body intrinsic; 5 | } 6 | 7 | 8 | operation Test (x : Int) : Unit { 9 | 10 | mutable y = 0; 11 | 12 | for i in 0 .. x { 13 | f(y + i); 14 | set y = y + 1; 15 | } 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleLibrary/Library.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.QSharpLibrary1 { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Chemistry; 5 | open Microsoft.Quantum.Intrinsic; 6 | open Quantum.ReferenceLibrary; 7 | 8 | 9 | operation HelloQ () : Unit { 10 | Message("Hello quantum world!"); 11 | LibraryOperation(); 12 | let x = HTerm([], []); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/CompilerExtensions/Demo/Demo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Detailed 5 | Exe 6 | net6.0 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestWhile.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | @EntryPoint() 7 | function TestWhile (a : Int, b : Int) : Int 8 | { 9 | mutable n = a; 10 | while (n < b) 11 | { 12 | set n = n * 2; 13 | } 14 | return n; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Documentation/DocumentationGenerator/DocumentationGenerator.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(MSBuildThisFileDirectory)/../lib/net6.0/Microsoft.Quantum.DocumentationGenerator.dll 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/QsCompiler/RoslynWrapper/cgmanifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/component-detection-manifest.json", 3 | "Registrations": [ 4 | { 5 | "component": { 6 | "type": "git", 7 | "git": { 8 | "repositoryUrl": "https://github.com/johnazariah/roslyn-wrapper.git", 9 | "commitHash": "49f5d9b9e26b0cc9925447e09a50b812df6f0cfb" 10 | } 11 | } 12 | } 13 | ], 14 | "Version": 1 15 | } 16 | -------------------------------------------------------------------------------- /src/QsCompiler/SyntaxProcessor/CapabilityInference/ResultAnalyzer.fsi: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | module internal Microsoft.Quantum.QsCompiler.SyntaxProcessing.CapabilityInference.ResultAnalyzer 5 | 6 | open Microsoft.Quantum.QsCompiler.SyntaxTree 7 | open Microsoft.Quantum.QsCompiler.Transformations.Core 8 | 9 | val analyzer: callableKind: QsCallableKind option -> Analyzer unit> 10 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test7/test7.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net461 4 | x64 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestDoubles.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | @EntryPoint() 7 | function TestDouble (x : Double, y : Double) : Double 8 | { 9 | let a = x + y - 2.0; 10 | let b = a * 1.235 + x ^ y; 11 | let c = a >= b ? a - b | a + b; 12 | return a * b * c; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestUdtAccessor.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | newtype TestType = ((Pauli, I : Int), D : Double); 7 | 8 | @EntryPoint() 9 | function TestAccessors() : Int 10 | { 11 | let x = TestType((PauliX, 1), 2.0); 12 | let y = x::I; 13 | return y; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/unittest/Tests.qs: -------------------------------------------------------------------------------- 1 | namespace <%= name %> { 2 | open Microsoft.Quantum.Canon; 3 | open Microsoft.Quantum.Diagnostics; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | 7 | @Test("QuantumSimulator") 8 | operation AllocateQubit() : Unit { 9 | 10 | use q = Qubit(); 11 | AssertMeasurement([PauliZ], [q], Zero, "Newly allocated qubit must be in |0> state."); 12 | 13 | Message("Test passed."); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleApplication/Program.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.QSharpApplication1 { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Chemistry; 5 | open Microsoft.Quantum.Intrinsic; 6 | open Quantum.ReferenceLibrary; 7 | 8 | 9 | @EntryPoint() 10 | operation HelloQ () : Unit { 11 | Message("Hello quantum world!"); 12 | LibraryOperation(); 13 | let x = HTerm([], []); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/QuantumSdk/ProjectSystem/Rules/ProjectItemsSchema.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/CompilerExtensions/ExtensionPackage/CompilerExtension.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(MSBuildThisFileDirectory)/../lib/net6.0/CustomExtension.dll; 7 | $(MSBuildThisFileDirectory)/../lib/net6.0/CustomExtension.Package.dll 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.Test1/Tests.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.Test1 { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Diagnostics; 5 | open Microsoft.Quantum.Intrinsic; 6 | 7 | 8 | @Test("QuantumSimulator") 9 | operation AllocateQubit() : Unit { 10 | 11 | use q = Qubit(); 12 | AssertMeasurement([PauliZ], [q], Zero, "Newly allocated qubit must be in |0> state."); 13 | 14 | Message("Test passed."); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test3/test3.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netstandard2.0 4 | x64 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Telemetry/Library/DataContracts/TelemetryPropertyType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Telemetry 5 | { 6 | /// 7 | /// Allowed property types for the telemetry events 8 | /// 9 | public enum TelemetryPropertyType 10 | { 11 | String, 12 | DateTime, 13 | Long, 14 | Double, 15 | Guid, 16 | Boolean, 17 | } 18 | } -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test17/MeasureBell.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.AzureSamples { 5 | open Microsoft.Quantum.Intrinsic; 6 | 7 | @EntryPoint() 8 | operation MeasureBell() : Bool { 9 | 10 | use (alice, bob) = (Qubit(), Qubit()); 11 | H(alice); 12 | CNOT(alice, bob); 13 | let (m1, m2) = (M(alice), M(bob)); 14 | return m1 == m2; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Telemetry/Samples/CSharp/CSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Exe 9 | sampleTelAppCs 10 | net6.0 11 | Microsoft.Quantum.Telemetry.Samples.CSharp 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/ProjectTemplates/README.md: -------------------------------------------------------------------------------- 1 | This folder contains the definitions for the NuGet package containing templates for Q# projects. These templates are provided for working with the command line; there is a separate set of templates each that is included with the VS and the VS Code extension. 2 | 3 | Microsoft documentation for creating custom templates: https://docs.microsoft.com/en-us/dotnet/core/tools/custom-templates 4 | 5 | The full schema for the template.json file: http://json.schemastore.org/template 6 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test15/test15.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | dotnet $(MSBuildProjectDirectory)/../../qsfmt/qsfmt.dll 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/QuantumSdk/Tools/DefaultEntryPoint/DefaultEntryPoint.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | Microsoft.Quantum.Sdk.DefaultEntryPoint.Generation 7 | Build tool to generate a minimal C# entry point when no C# files are included in the compilation. 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpTestTemplate/Tests.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.$safeprojectname$ { 2 | open Microsoft.Quantum.Canon; 3 | open Microsoft.Quantum.Diagnostics; 4 | open Microsoft.Quantum.Intrinsic; 5 | 6 | 7 | @Test("QuantumSimulator") 8 | operation AllocateQubit () : Unit { 9 | 10 | use q = Qubit(); 11 | AssertMeasurement([PauliZ], [q], Zero, "Newly allocated qubit must be in |0> state."); 12 | 13 | Message("Test passed."); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestIntegers.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | @EntryPoint() 7 | function TestInts (a : Int, b : Int) : Int { 8 | let c = a > b ? a | b; 9 | let d = c * a - b / 7; 10 | let e = d >>> 3; 11 | let f = d ^ b; 12 | let g = (e &&& f) ||| 0xffff; 13 | return ~~~g; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/QsFmt/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "QsFmt", 6 | "type": "coreclr", 7 | "request": "launch", 8 | "preLaunchTask": "build", 9 | "program": "${workspaceFolder}/App/bin/Debug/netcoreapp3.1/qsfmt.dll", 10 | "args": ["--TELEMETRY_TEST_MODE"], 11 | "console": "integratedTerminal", 12 | "stopAtEntry": false 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.LanguageServer/MsBuildDefaultsRegistration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | using Microsoft.Build.Locator; 6 | 7 | namespace Microsoft.Quantum.QsLanguageServer.Testing 8 | { 9 | internal static class MsBuildDefaults 10 | { 11 | public static Lazy LazyRegistration { get; } 12 | = new Lazy(MSBuildLocator.RegisterDefaults); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Telemetry/Tests.OutOfProcessExe/OutOfProcessExe.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Exe 9 | outofprocess 10 | net6.0 11 | Microsoft.Quantum.Telemetry.Tests.OutOfProcess 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test13/test13.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | x64 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestDeclarations2.ll: -------------------------------------------------------------------------------- 1 | define internal void @Microsoft__Quantum__Testing__QIR__SelfAdjointIntrinsic__ctladj(%Array* %__controlQubits__, %Tuple* %__unitArg__) { 2 | entry: 3 | call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i32 1) 4 | call void @__quantum__qis__selfadjointintrinsic__ctl(%Array* %__controlQubits__, %Tuple* %__unitArg__) 5 | call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i32 -1) 6 | ret void 7 | } 8 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/OptimizerTests/TypedParameters_input.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /// This namespace contains test cases for optimization dealing with typed parameters 5 | namespace Microsoft.Quantum.Arrays { 6 | function Length<'T>(array : 'T[]) : Int { 7 | body intrinsic; 8 | } 9 | 10 | function IndexRange<'T>(array : 'T[]) : Range { 11 | return 0..Length(array) - 1; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestDeclarations6.ll: -------------------------------------------------------------------------------- 1 | define internal void @Microsoft__Quantum__Testing__QIR__SelfAdjointOp__ctladj(%Array* %__controlQubits__, %Tuple* %__unitArg__) { 2 | entry: 3 | call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i32 1) 4 | call void @Microsoft__Quantum__Testing__QIR__SelfAdjointOp__ctl(%Array* %__controlQubits__, %Tuple* %__unitArg__) 5 | call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i32 -1) 6 | ret void 7 | } 8 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestResults.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | @EntryPoint() 7 | function TestResults (a : Result, b : Result) : Result 8 | { 9 | if (a == b) 10 | { 11 | return One; 12 | } 13 | elif (a == One) 14 | { 15 | return b; 16 | } 17 | return Zero; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/QsFmt/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/App/App.fsproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/stylecop.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", 3 | "settings": { 4 | "orderingRules": { 5 | "usingDirectivesPlacement": "preserve" 6 | }, 7 | "documentationRules": { 8 | "documentInterfaces": false, 9 | "documentExposedElements": false, 10 | "documentInternalElements": false, 11 | "xmlHeader": false 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test5/Tests5.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace test5 { 5 | open Microsoft.Quantum.Canon; 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | operation AllocateQubitTest () : Unit { 9 | 10 | using (qs = Qubit[1]) { 11 | Assert([PauliZ], [qs[0]], Zero, "Newly allocated qubit must be in |0> state"); 12 | } 13 | 14 | Message("Test passed"); 15 | } 16 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/WholeFileTests/ConflictingAliases.qs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.Testing.FirstExampleNs { 2 | operation Foo(): Unit { 3 | } 4 | } 5 | 6 | namespace Microsoft.Quantum.Testing.SecondExampleNs { 7 | operation Bar(): Unit { 8 | } 9 | } 10 | 11 | namespace Microsoft.Quantum.Testing.ThirdExampleNs { 12 | open Microsoft.Quantum.Testing.FirstExampleNs as A; 13 | open Microsoft.Quantum.Testing.SecondExampleNs as A; 14 | 15 | operation Baz(): Unit { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test9/test9.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | x64 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestUdt.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | internal newtype Foo = Unit; 7 | internal newtype Bar = Int; 8 | newtype TestType = ((Pauli, I : Int), D : Double); 9 | 10 | @EntryPoint() 11 | operation Main() : Unit { 12 | let _ = TestType((PauliI, 0), 0.); 13 | let _ = [Foo()]; 14 | let _ = [Bar(1)]; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Telemetry/Library/Commands/IOutOfProcessSerializer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace Microsoft.Quantum.Telemetry.Commands 7 | { 8 | public interface ICommandSerializer 9 | { 10 | IEnumerable Write(IEnumerable commands); 11 | 12 | IEnumerable Write(CommandBase command); 13 | 14 | IEnumerable Read(IEnumerable messages); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/OptimizerTests/Reordering_input.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /// This namespace contains test cases for statement reordering 5 | namespace Microsoft.Quantum.Testing.Optimization.Reordering { 6 | operation Test (x : Int) : Unit { 7 | let y = x + 2; 8 | f(y); 9 | let z = y + 2; 10 | f(z); 11 | } 12 | 13 | operation f (n : Int) : Unit { 14 | body intrinsic; 15 | } 16 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestGenerics3.ll: -------------------------------------------------------------------------------- 1 | define internal void @Microsoft__Quantum__Testing__QIR__DumpRegisterTest__body() { 2 | entry: 3 | %q2 = call %Array* @__quantum__rt__qubit_allocate_array(i64 2) 4 | call void @__quantum__rt__array_update_alias_count(%Array* %q2, i32 1) 5 | call void @__quantum__qis__dumpregister__body(i8* null, %Array* %q2) 6 | call void @__quantum__rt__array_update_alias_count(%Array* %q2, i32 -1) 7 | call void @__quantum__rt__qubit_release_array(%Array* %q2) 8 | ret void 9 | } 10 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/OldApplication/OldApplication.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | x64 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/QIR/Simulation/StateSimulator/include/Eigen/README.md: -------------------------------------------------------------------------------- 1 | Replace this file with the [Eigen library](http://eigen.tuxfamily.org/), including the unsupported modules `KroneckerProduct` and `MatrixFunctions`, by copying the following files: 2 | 3 | - `Eigen/*` -> `./` 4 | - `unsupported/Eigen/KroneckerProduct` -> `./KroneckerProduct` 5 | - `unsupported/Eigen/src/KroneckerProduct/*` -> `./src/KroneckerProduct/` 6 | - `unsupported/Eigen/MatrixFunctions` -> `./MatrixFunctions` 7 | - `unsupported/Eigen/src/MatrixFunctions/*` -> `./src/MatrixFunctions/` 8 | -------------------------------------------------------------------------------- /src/QsCompiler/TestTargets/Libraries/Library2/Library.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing 5 | { 6 | open Microsoft.Quantum.Diagnostics; 7 | open Microsoft.Quantum.Intrinsic; 8 | 9 | /// # Summary 10 | /// Logs the given message of the given severity. 11 | @EnableTestingViaName("Library2.Log") 12 | function Log (severity : Int, msg : String) : Unit { 13 | Message("not implemented"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Telemetry/Library/DataContracts/SerializeJsonAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | 6 | namespace Microsoft.Quantum.Telemetry 7 | { 8 | /// 9 | /// Serializes the property as Json 10 | /// 11 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] 12 | public sealed class SerializeJsonAttribute : Attribute 13 | { 14 | public SerializeJsonAttribute() 15 | { 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /examples/QIR/Development/Program.qs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.Qir.Development { 2 | 3 | open Microsoft.Quantum.Arrays; 4 | open Microsoft.Quantum.Canon; 5 | open Microsoft.Quantum.Diagnostics; 6 | open Microsoft.Quantum.Intrinsic; 7 | open Microsoft.Quantum.Math; 8 | 9 | @EntryPoint() 10 | operation RunExample() : String { 11 | 12 | // Add additional code here 13 | // for experimenting with and debugging QIR generation. 14 | 15 | return "Executed successfully!"; 16 | } 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestRange.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | @EntryPoint() 7 | function TestRange () : Range 8 | { 9 | let x = 0..2..6; 10 | let a = [0, 2, 4, 6, 8, 10, 12, 14, 16]; 11 | let b = a[x]; 12 | 13 | let y = 0..4; 14 | for j in y 15 | { 16 | let m = 1; 17 | } 18 | return x; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/QuantumSdk/Tools/BuildConfiguration/BuildConfiguration.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | Microsoft.Quantum.Sdk.BuildConfiguration 7 | Build configuration tools included in the Microsoft Quantum Sdk. 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Telemetry/Library/DataContracts/TelemetryExceptionRecord.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Telemetry 5 | { 6 | /// 7 | /// Contains non-sensitive/identifiable information from an Exception 8 | /// 9 | public class TelemetryExceptionRecord 10 | { 11 | public string? FullName { get; set; } 12 | 13 | public string? TargetSite { get; set; } 14 | 15 | public string? StackTrace { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestLibraryGeneration.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR { 5 | open Microsoft.Quantum.Intrinsic; 6 | 7 | operation Foo(c1 : Int, c2 : Bool) : Bool { 8 | return Bar(c1 > 0 and c2); 9 | } 10 | 11 | operation Bar<'T>(a1 : 'T) : 'T { 12 | return a1; 13 | } 14 | 15 | operation Baz(q : Qubit) : Unit is Adj { 16 | H(q); 17 | T(q); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/QuantumSdk/ProjectSystem/ProjectSystem.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 7 | 8 | 9 | 10 | 11 | false 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/OptimizerTests/NoOp_input.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /// This namespace contains test cases where no optimizations can be done 5 | namespace Microsoft.Quantum.Testing.Optimization.NoOp { 6 | operation Test (x : Int) : Unit { 7 | mutable y = 0; 8 | for (i in 0..x) { 9 | f(y + i); 10 | set y += 1; 11 | } 12 | } 13 | 14 | operation f (n : Int) : Unit { 15 | body intrinsic; 16 | } 17 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestDeconstruct.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | function TestDeconstruct (a : (Int, (Int, Int))) : Int 7 | { 8 | let (x, y) = a; 9 | mutable b = 3; 10 | mutable c = 5; 11 | set (b, c) = y; 12 | return x + b * c; 13 | } 14 | 15 | @EntryPoint() 16 | function Main() : Unit { 17 | let _ = TestDeconstruct(0, (0, 0)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/ExecutionTests/QirTargetingTests.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.ExecutionTests { 5 | 6 | open Microsoft.Quantum.Intrinsic; 7 | open Microsoft.Quantum.Measurement; 8 | open Microsoft.Quantum.Canon; 9 | 10 | @EntryPoint() 11 | operation TestTargetPackageHandling() : Unit { 12 | 13 | use qs = Qubit[2]; 14 | Ignore(Measure([PauliX, PauliX], qs)); 15 | ResetAll(qs); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestShortCircuiting.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | operation GetRandomBool(seed : Int) : Bool { 7 | body intrinsic; 8 | } 9 | 10 | @EntryPoint() 11 | operation TestShortCircuiting () : (Bool, Bool) { 12 | let rand = GetRandomBool(1) and GetRandomBool(2); 13 | let ror = GetRandomBool(3) or GetRandomBool(4); 14 | return (rand, ror); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/QsFmt/App/DesignTimeBuild.fsi: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | module internal Microsoft.Quantum.QsFmt.App.DesignTimeBuild 5 | 6 | /// Given a path to a project file, returns the list of files associated 7 | /// to the project and the Quantum SDK version. 8 | /// Errors if given a file that is not a project file using Microsoft.Quantum.Sdk. 9 | val getSourceFiles: string -> string list * string 10 | 11 | /// Initializes the assembly load context needed for building project files. 12 | val assemblyLoadContextSetup: Unit -> Unit 13 | -------------------------------------------------------------------------------- /examples/QIR/Emission/README.md: -------------------------------------------------------------------------------- 1 | # Generating QIR 2 | 3 | This project contains an example for how to use the Q# compiler to emit QIR in human readable form. 4 | For more information about QIR and the features, please see this [readme](../../../src/QsCompiler/QirGeneration/README.md). 5 | 6 | This project compiles using a *released* version of the compiler and QIR generation. If you intend to develop/modify the QIR generation and/or the compiler, please take a look at the [Development project](../Development) instead, which is compiled using the source code version of the compiler and QIR generation. 7 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestBools.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | @EntryPoint() 7 | function TestBools (a : Bool, b : Bool) : Bool 8 | { 9 | let c = a == b ? a | b; 10 | let d = a and b; 11 | let e = a or b; 12 | let f = not a; 13 | if (f) 14 | { 15 | return d; 16 | } 17 | else 18 | { 19 | return e; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/VSCodeExtension/README.md: -------------------------------------------------------------------------------- 1 | # Microsoft Quantum Development Kit 2 | 3 | ## DEPRECATION NOTICE 4 | 5 | **This extension is deprecated.** 6 | 7 | For the latest Q# and Azure Quantum development experience, please use the Azure Quantum Development Kit (Modern QDK) [VS Code extension](https://marketplace.visualstudio.com/items?itemName=quantum.qsharp-lang-vscode). 8 | 9 | You can also try out the Modern QDK in VS Code for Web at [vscode.dev/quantum](https://vscode.dev/quantum). 10 | 11 | For more information about the Modern QDK and Azure Quantum, visit https://aka.ms/AQ/Documentation 12 | -------------------------------------------------------------------------------- /llvm-build/header.txt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Changes to this file may cause incorrect behavior and will be lost if 5 | // the code is regenerated. 6 | // 7 | //------------------------------------------------------------------------------ 8 | -------------------------------------------------------------------------------- /src/QsCompiler/RoslynWrapper/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/WholeFileTests/OpenWithAlias.qs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.Testing.FirstExampleNs { 2 | operation Foo(): Unit { 3 | } 4 | 5 | newtype Complex = (Real: Double, Imaginary : Double); 6 | } 7 | 8 | namespace Microsoft.Quantum.Testing.SecondExampleNs { 9 | open Microsoft.Quantum.Testing.FirstExampleNs; 10 | open Microsoft.Quantum.Testing.FirstExampleNs as A; 11 | 12 | operation Baz(): Unit { 13 | A.Foo(); 14 | Foo(); 15 | 16 | let i1 = Complex(0.0, 1.0); 17 | let i2 = A.Complex(0.0, 1.0); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/VSCodeExtension/language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "lineComment": "//", 4 | }, 5 | // symbols used as brackets 6 | "brackets": [ 7 | ["[", "]"], 8 | ["(", ")"], 9 | ["{", "}"] 10 | ], 11 | // symbols that are auto closed when typing 12 | "autoClosingPairs": [ 13 | ["[", "]"], 14 | ["(", ")"], 15 | ["{", "}"] 16 | ], 17 | // symbols that that can be used to surround a selection 18 | "surroundingPairs": [ 19 | ["[", "]"], 20 | ["(", ")"], 21 | ["{", "}"] 22 | ] 23 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestGenerics4.ll: -------------------------------------------------------------------------------- 1 | define internal void @Microsoft__Quantum__Testing__QIR__DumpRegisterToFileTest__body(%String* %filePath) { 2 | entry: 3 | %q2 = call %Array* @__quantum__rt__qubit_allocate_array(i64 2) 4 | call void @__quantum__rt__array_update_alias_count(%Array* %q2, i32 1) 5 | %0 = bitcast %String* %filePath to i8* 6 | call void @__quantum__qis__dumpregister__body(i8* %0, %Array* %q2) 7 | call void @__quantum__rt__array_update_alias_count(%Array* %q2, i32 -1) 8 | call void @__quantum__rt__qubit_release_array(%Array* %q2) 9 | ret void 10 | } 11 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestIntegers.ll: -------------------------------------------------------------------------------- 1 | define internal i64 @Microsoft__Quantum__Testing__QIR__TestInts__body(i64 %a, i64 %b) { 2 | entry: 3 | %0 = icmp sgt i64 %a, %b 4 | %c = select i1 %0, i64 %a, i64 %b 5 | %1 = mul i64 %c, %a 6 | %2 = sdiv i64 %b, 7 7 | %d = sub i64 %1, %2 8 | %e = ashr i64 %d, 3 9 | %3 = sitofp i64 %d to double 10 | %4 = trunc i64 %b to i32 11 | %5 = call double @llvm.powi.f64.i32(double %3, i32 %4) 12 | %f = fptosi double %5 to i64 13 | %6 = and i64 %e, %f 14 | %g = or i64 %6, 65535 15 | %7 = xor i64 %g, -1 16 | ret i64 %7 17 | } 18 | -------------------------------------------------------------------------------- /src/Common/stylecop.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", 3 | "settings": { 4 | "orderingRules": { 5 | "usingDirectivesPlacement": "preserve" 6 | }, 7 | "documentationRules": { 8 | "copyrightText": "Copyright (c) Microsoft Corporation.\nLicensed under the MIT License.", 9 | "documentInterfaces": false, 10 | "documentExposedElements": false, 11 | "documentInternalElements": false, 12 | "xmlHeader": false 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.Test1/.template.config/template.json.v.template: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/template", 3 | "classifications": ["Test", "xUnit"], 4 | "name": "xUnit Test Project", 5 | "description": "A project for creating unit tests in Q#.", 6 | "groupIdentity": "Microsoft.Test.xUnit", 7 | "identity": "Microsoft.Test.xUnit.QSharp.#MAJOR_VERSION#.#MINOR_VERSION#", 8 | "shortName": "xunit", 9 | "tags": { 10 | "language": "Q#", 11 | "type": "project" 12 | }, 13 | "sourceName": "Quantum.Test1", 14 | "preferNameDirectory": true 15 | } -------------------------------------------------------------------------------- /src/VSCodeExtension/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "watch", 9 | "problemMatcher": "$tsc-watch", 10 | "isBackground": true, 11 | "presentation": { 12 | "reveal": "silent" 13 | }, 14 | "group": { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Extensions/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 3 | // Portions Copyright (c) Microsoft Corporation 4 | // 5 | 6 | using System; 7 | using System.Text; 8 | 9 | namespace LlvmBindings.Interop 10 | { 11 | public static unsafe class StringExtensions 12 | { 13 | public static MarshaledString AsMarshaledString(this string self) 14 | { 15 | return new MarshaledString(self.AsSpan()); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Interop/LLVMAttributeIndex.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). 2 | // Ported from https://github.com/llvm/llvm-project 3 | // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. 4 | 5 | namespace LlvmBindings.Interop 6 | { 7 | public enum LLVMAttributeIndex 8 | { 9 | LLVMAttributeReturnIndex = 0, 10 | LLVMAttributeFunctionIndex = -1, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/QsCompiler/TestTargets/Simulation/Example/Main.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.Simulation 5 | { 6 | open Microsoft.Quantum.Intrinsic; 7 | open Microsoft.Quantum.Testing; 8 | 9 | 10 | /// # Summary 11 | /// This operation serves as main entry point of the application 12 | /// and will be executed on the quantum simulator. 13 | @EntryPoint() 14 | operation Main () : Unit { 15 | 16 | // add the code to execute 17 | Log(0, "Welcome to Q#!"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.Library1/.template.config/template.json.v.template: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/template", 3 | "classifications": ["Common", "Library"], 4 | "name": "Class library", 5 | "description": "A project for creating a Q# library.", 6 | "groupIdentity": "Microsoft.Common.Library", 7 | "identity": "Microsoft.Common.Library.QSharp.#MAJOR_VERSION#.#MINOR_VERSION#", 8 | "shortName": "classlib", 9 | "tags": { 10 | "language": "Q#", 11 | "type": "project" 12 | }, 13 | "sourceName": "Quantum.Library1", 14 | "preferNameDirectory": true 15 | } -------------------------------------------------------------------------------- /src/QsCompiler/CommandLineTool/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Telemetry/Library/Commands/CommandBase.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Telemetry.Commands 5 | { 6 | public abstract class CommandBase 7 | { 8 | public CommandBase(CommandType commandType, object? args = null) 9 | { 10 | this.CommandType = commandType; 11 | this.Args = args; 12 | } 13 | 14 | public CommandType CommandType { get; set; } 15 | 16 | public object? Args { get; set; } 17 | 18 | public abstract void Process(ICommandProcessor server); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.App1/.template.config/template.json.v.template: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/template", 3 | "classifications": ["Common", "Console"], 4 | "name": "Console Application", 5 | "description": "A project for creating a Q# command-line application.", 6 | "groupIdentity": "Microsoft.Common.Console", 7 | "identity": "Microsoft.Common.Console.QSharp.#MAJOR_VERSION#.#MINOR_VERSION#", 8 | "shortName": "console", 9 | "tags": { 10 | "language": "Q#", 11 | "type": "project" 12 | }, 13 | "sourceName": "Quantum.App1", 14 | "preferNameDirectory": true 15 | } -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test4/test4.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | x64 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/QsCompiler/TestTargets/Libraries/Library1/Logging.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing 5 | { 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | /// # Summary 9 | /// Logs the given message of the given severity. 10 | function Log (severity : Int, msg : String) : Unit { 11 | let intro = 12 | severity >= 3 ? "Error: " 13 | | severity == 2 ? "Warning: " 14 | | severity == 1 ? "Info: " 15 | | ""; 16 | Message($"{intro}{msg}"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestBools.ll: -------------------------------------------------------------------------------- 1 | define internal i1 @Microsoft__Quantum__Testing__QIR__TestBools__body(i1 %a, i1 %b) { 2 | entry: 3 | %0 = icmp eq i1 %a, %b 4 | %c = select i1 %0, i1 %a, i1 %b 5 | %d = and i1 %a, %b 6 | %e = or i1 %a, %b 7 | %f = xor i1 %a, true 8 | br i1 %f, label %then0__1, label %else__1 9 | 10 | then0__1: ; preds = %entry 11 | ret i1 %d 12 | 13 | else__1: ; preds = %entry 14 | ret i1 %e 15 | 16 | continue__1: ; No predecessors! 17 | unreachable 18 | } 19 | -------------------------------------------------------------------------------- /src/QsFmt/Formatter/Errors.fsi: -------------------------------------------------------------------------------- 1 | /// Parse tree error handling. 2 | module Microsoft.Quantum.QsFmt.Formatter.Errors 3 | 4 | open Antlr4.Runtime 5 | 6 | /// A syntax error that can occur during parsing. 7 | type SyntaxError 8 | 9 | /// Builds a list of syntax errors that occur during parsing. 10 | [] 11 | type internal ListErrorListener = 12 | /// 13 | /// Creates a new . 14 | /// 15 | new: unit -> ListErrorListener 16 | 17 | /// The accumulated syntax errors. 18 | member SyntaxErrors: SyntaxError list 19 | 20 | interface IToken IAntlrErrorListener 21 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/WholeFileTests/DuplicateOpens.qs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.Testing.FirstExampleNs { 2 | operation Foo(): Unit { 3 | } 4 | } 5 | 6 | namespace Microsoft.Quantum.Testing.SecondExampleNs { 7 | open Microsoft.Quantum.Testing.FirstExampleNs; 8 | open Microsoft.Quantum.Testing.FirstExampleNs as A; 9 | open Microsoft.Quantum.Testing.FirstExampleNs; 10 | open Microsoft.Quantum.Testing.FirstExampleNs as A; 11 | open Microsoft.Quantum.Testing.FirstExampleNs as B; 12 | 13 | operation Baz(): Unit { 14 | A.Foo(); 15 | Foo(); 16 | B.Foo(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Common/AssemblyCommon.cs.v.template: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | // General Information about an assembly is controlled through the following 4 | // set of attributes. Change these attribute values to modify the information 5 | // associated with an assembly. 6 | [assembly: AssemblyConfiguration("")] 7 | [assembly: AssemblyCompany("Microsoft")] 8 | [assembly: AssemblyProduct("Microsoft Quantum Development Kit Preview")] 9 | [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] 10 | [assembly: AssemblyTrademark("")] 11 | [assembly: AssemblyCulture("")] 12 | 13 | [assembly: AssemblyVersion("#ASSEMBLY_VERSION#")] 14 | -------------------------------------------------------------------------------- /src/VSCodeExtension/src/decompress-zip.d.ts: -------------------------------------------------------------------------------- 1 | declare class DecompressZip { 2 | constructor(path : string); 3 | on(event : 'error', callback : (err : any) => void) : void; 4 | on(event : 'extract', callback : (log : any) => void) : void; 5 | on(event : 'progress', callback : (fileIndex : number, fileCount : number) => void) : void; 6 | extract(options : { 7 | path? : string, 8 | follow? : boolean, 9 | filter? : (file : string) => boolean, 10 | strip? : number, 11 | restrict?: boolean 12 | }) : void; 13 | } 14 | 15 | declare module 'decompress-zip' { 16 | export = DecompressZip; 17 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/AttributeGeneration.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.AttributeGeneration { 5 | 6 | open Microsoft.Quantum.Arrays; 7 | 8 | function DefaultArray<'A>(size : Int) : 'A[] { 9 | mutable arr = new 'A[size]; 10 | for (i in IndexRange(arr)) { 11 | set arr w/= i <- Default<'A>(); 12 | } 13 | return arr; 14 | } 15 | 16 | operation CallDefaultArray<'A>(size : Int) : 'A[] { 17 | return DefaultArray<'A>(size); 18 | } 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/WholeFileTests/DuplicateAndConflictingAliases.qs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.Testing.FirstExampleNs { 2 | operation Foo(): Unit { 3 | } 4 | } 5 | 6 | namespace Microsoft.Quantum.Testing.SecondExampleNs { 7 | operation Bar(): Unit { 8 | } 9 | } 10 | 11 | namespace Microsoft.Quantum.Testing.ThirdExampleNs { 12 | open Microsoft.Quantum.Testing.FirstExampleNs; 13 | open Microsoft.Quantum.Testing.SecondExampleNs; 14 | open Microsoft.Quantum.Testing.FirstExampleNs as A; 15 | open Microsoft.Quantum.Testing.SecondExampleNs as A; 16 | 17 | operation Baz(): Unit { 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestUdtConstruction.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | newtype Complex = (Re : Double, Im : Double); 7 | newtype TestType = ((Pauli, I : Int), D : Double); 8 | 9 | function TestUdtConstructor() : TestType 10 | { 11 | let args = (1.,2.); 12 | let complex = Complex(args); 13 | return TestType((PauliX, 1), 2.0); 14 | } 15 | 16 | @EntryPoint() 17 | function Main() : Unit { 18 | let _ = TestUdtConstructor(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/QIR/JITCompilation/Hello.ll: -------------------------------------------------------------------------------- 1 | %String = type opaque 2 | 3 | @0 = internal constant [21 x i8] c"Hello quantum world!\00" 4 | 5 | define void @Hello__HelloQ() { 6 | entry: 7 | %0 = call %String* @__quantum__rt__string_create(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @0, i32 0, i32 0)) 8 | call void @__quantum__rt__message(%String* %0) 9 | call void @__quantum__rt__string_update_reference_count(%String* %0, i32 -1) 10 | ret void 11 | } 12 | 13 | declare %String* @__quantum__rt__string_create(i8*) 14 | 15 | declare void @__quantum__rt__message(%String*) 16 | 17 | declare void @__quantum__rt__string_update_reference_count(%String*, i32) 18 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Extensions/LLVMMCJITCompilerOptionsExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). 2 | 3 | using System; 4 | using System.Runtime.InteropServices; 5 | 6 | namespace LlvmBindings.Interop 7 | { 8 | public unsafe partial struct LLVMMCJITCompilerOptions 9 | { 10 | public static LLVMMCJITCompilerOptions Create() 11 | { 12 | LLVMMCJITCompilerOptions options; 13 | LLVM.InitializeMCJITCompilerOptions(&options, (UIntPtr)Marshal.SizeOf()); 14 | return options; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/QsCompiler/TestTargets/Libraries/Library1/Library1.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Library 4 | net6.0 5 | QS7010;QS7009 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/QsCompiler/TestTargets/Libraries/Library2/Library2.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Library 4 | net6.0 5 | QS7010;QS7009 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/RepeatArray.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR { 5 | @EntryPoint() 6 | operation Main() : Int { 7 | use register = Qubit[5]; 8 | mutable count = 0; 9 | repeat { 10 | let results = MultiM(register); 11 | if results[0] == Zero { 12 | set count += 1; 13 | } 14 | } 15 | until count < 5; 16 | return count; 17 | } 18 | 19 | operation MultiM(targets : Qubit[]) : Result[] { 20 | body intrinsic; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/QsFmt/App.Tests/Examples/TestProjects/SimpleTestProject/Tests.qs: -------------------------------------------------------------------------------- 1 | namespace Quantum.QSharpTestProject1 { 2 | 3 | open Microsoft.Quantum.Canon; 4 | open Microsoft.Quantum.Chemistry; 5 | open Microsoft.Quantum.Diagnostics; 6 | open Microsoft.Quantum.Intrinsic; 7 | open Quantum.ReferenceLibrary; 8 | 9 | 10 | @Test("QuantumSimulator") 11 | operation AllocateQubit () : Unit { 12 | 13 | use q = Qubit(); 14 | AssertMeasurement([PauliZ], [q], Zero, "Newly allocated qubit must be in |0> state."); 15 | 16 | Message("Test passed."); 17 | LibraryOperation(); 18 | let x = HTerm([], []); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Telemetry/Library/DataContracts/PiiDataAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | 6 | namespace Microsoft.Quantum.Telemetry 7 | { 8 | /// 9 | /// Apply the PIIData attribute to properties or fields that should be 10 | /// tagged as PII in the telemetry. The values of these fields will 11 | /// be hashed with a rotating salt. 12 | /// 13 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] 14 | public sealed class PiiDataAttribute : Attribute 15 | { 16 | public PiiDataAttribute() 17 | { 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.CSharpGeneration/Circuits/TargetedExe.qs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.Testing { 2 | open Microsoft.Quantum.Intrinsic; 3 | 4 | internal operation MeasureEach(qs : Qubit[]) : Result[] { 5 | 6 | mutable res = [Zero, size = Length(qs)]; 7 | for i in 0..Length(qs) { 8 | if M(qs[i]) == One { 9 | set res w/= i <- One; 10 | } 11 | } 12 | 13 | return res; 14 | } 15 | 16 | internal operation Ignore<'T> (arg : 'T) : Unit {} 17 | 18 | operation Main() : Int { 19 | 20 | use qs = Qubit[2]; 21 | Ignore(MeasureEach(qs)); 22 | return 12345; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Telemetry/Library/Commands/QuitCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Telemetry.Commands 5 | { 6 | public class QuitCommand : CommandBase 7 | { 8 | public QuitCommand() 9 | : base(CommandType.Quit) 10 | { 11 | } 12 | 13 | public override bool Equals(object? obj) => 14 | obj is QuitCommand; 15 | 16 | public override int GetHashCode() => 17 | this.CommandType.GetHashCode(); 18 | 19 | public override void Process(ICommandProcessor server) => 20 | server.ProcessCommand(this); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/ExecutionTests/Packaging.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.ExecutionTests { 5 | open Microsoft.Quantum.Intrinsic; 6 | open Microsoft.Quantum.Testing; 7 | 8 | @EntryPoint() 9 | operation PackageAndProjectReference () : Unit { 10 | Message("Welcome to Q#!"); 11 | Log(1, "Go check out https://docs.microsoft.com/azure/quantum."); 12 | } 13 | 14 | @EntryPoint() 15 | operation TypeInReferencedProject () : Unit { 16 | let arr = [Complex(1., 0.)]; 17 | Message($"{arr}"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/QsFmt/Formatter.Tests/Errors.fs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | /// Tests for error handling. 5 | module Microsoft.Quantum.QsFmt.Formatter.Tests.Errors 6 | 7 | open Microsoft.Quantum.QsFmt.Formatter 8 | open Xunit 9 | 10 | [] 11 | let ``Returns error result with syntax errors`` () = 12 | let result = 13 | Formatter.format None "namespace Foo { invalid syntax; }" |> Result.mapError (List.map string) 14 | 15 | let error = 16 | "Line 1, Character 16: mismatched input 'invalid' expecting {'function', 'internal', 'newtype', 'open', 'operation', '@', '}'}" 17 | 18 | Assert.Equal(Error [ error ], result) 19 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using System; 9 | using System.Resources; 10 | using System.Runtime.InteropServices; 11 | 12 | [assembly: CLSCompliant(false)] 13 | 14 | // This assembly does not expose COM types 15 | [assembly: ComVisible(false)] 16 | 17 | [assembly: NeutralResourcesLanguage("en")] 18 | -------------------------------------------------------------------------------- /src/VSCodeExtension/templates/unittest/Test.csproj.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.IonQ.App1/.template.config/template.json.v.template: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/template", 3 | "classifications": ["Common", "Console"], 4 | "name": "Quantum Application IonQ", 5 | "description": "A project creating a Q# application that can be executed on an IonQ backend via Azure Quantum.", 6 | "groupIdentity": "Microsoft.Common.Console.IonQ", 7 | "identity": "Microsoft.Common.Console.QSharp.IonQ.#MAJOR_VERSION#.#MINOR_VERSION#", 8 | "shortName": "azq-ionq", 9 | "tags": { 10 | "language": "Q#", 11 | "type": "project" 12 | }, 13 | "sourceName": "Quantum.IonQ.App1", 14 | "preferNameDirectory": true 15 | } -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.Test1/Quantum.Test1.csproj.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/OptimizerTests/Arithmetic_output.txt: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.Testing.Optimization.Arithmetic { 2 | 3 | operation Test () : Int { 4 | 5 | return 4; 6 | } 7 | 8 | 9 | operation TestArithmeticForBigInt (x : BigInt) : BigInt { 10 | 11 | let y = x + x; 12 | return y; 13 | } 14 | 15 | 16 | operation TestArithmeticForDouble (x : Double) : Double { 17 | 18 | let y = x + x; 19 | return y; 20 | } 21 | 22 | 23 | operation TestArithmeticForInt (x : Int) : Int { 24 | 25 | let y = x + x; 26 | return y; 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestDeclarations1.ll: -------------------------------------------------------------------------------- 1 | define internal void @Microsoft__Quantum__Testing__QIR__SelfAdjointIntrinsic__adj() { 2 | entry: 3 | call void @__quantum__qis__selfadjointintrinsic__body() 4 | ret void 5 | } 6 | 7 | define internal void @Microsoft__Quantum__Testing__QIR__SelfAdjointIntrinsic__ctl(%Array* %__controlQubits__, %Tuple* %__unitArg__) { 8 | entry: 9 | call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i32 1) 10 | call void @__quantum__qis__selfadjointintrinsic__ctl(%Array* %__controlQubits__, %Tuple* %__unitArg__) 11 | call void @__quantum__rt__array_update_alias_count(%Array* %__controlQubits__, i32 -1) 12 | ret void 13 | } 14 | -------------------------------------------------------------------------------- /src/VisualStudioExtension/QSharpTestTemplate/TestProjectTemplate.xml.v.template: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/QsCompiler/CompilationManager/FileContentException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | using System; 5 | 6 | namespace Microsoft.Quantum.QsCompiler.CompilationBuilder 7 | { 8 | /// 9 | /// An exception that is thrown when an attempt is made to access content that is not part of a file. 10 | /// 11 | public class FileContentException : Exception 12 | { 13 | /// 14 | /// Creates a with the given message. 15 | /// 16 | public FileContentException(string message) 17 | : base(message) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/RoslynWrapper/WhileStatement.fs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.RoslynWrapper 2 | 3 | #nowarn "1182" // Unused parameters 4 | 5 | /// 6 | /// Generate while statements 7 | /// 8 | [] 9 | module WhileStatement = 10 | open Microsoft.CodeAnalysis 11 | open Microsoft.CodeAnalysis.CSharp 12 | open Microsoft.CodeAnalysis.CSharp.Syntax 13 | 14 | let private createBlock (stmts: StatementSyntax list) = 15 | stmts |> (Seq.toArray >> SyntaxFactory.Block) 16 | 17 | 18 | // while (condition) { statements } 19 | let ``while`` ``(`` condition ``)`` statements = 20 | (condition, createBlock statements) |> SyntaxFactory.WhileStatement :> StatementSyntax 21 | -------------------------------------------------------------------------------- /src/Telemetry/Library/TelemetryManagerConstants.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Telemetry 5 | { 6 | public static class TelemetryManagerConstants 7 | { 8 | internal const string TOKEN = "55aee962ee9445f3a86af864fc0fa766-48882422-3439-40de-8030-228042bd9089-7794"; 9 | public const string OUTOFPROCESSUPLOADARG = "--OUT_OF_PROCESS_TELEMETRY_UPLOAD"; 10 | public const string TESTMODE = "--TELEMETRY_TEST_MODE"; 11 | 12 | #if DEBUG 13 | public const bool IsDebugBuild = true; 14 | #else 15 | public const bool IsDebugBuild = false; 16 | #endif 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement, needs triage 6 | assignees: '' 7 | --- 8 | 9 | **Is your feature request related to a problem? Please describe.** 10 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 11 | 12 | **Describe the solution you'd like** 13 | A clear and concise description of what you want to happen. 14 | 15 | **Describe alternatives you've considered** 16 | A clear and concise description of any alternative solutions or features you've considered. 17 | 18 | **Additional context** 19 | Add any other context or screenshots about the feature request here. 20 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/OptimizerTests/Inlining_output.txt: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.Testing.Optimization.Inlining { 2 | 3 | operation f (q : Qubit, n : Int) : Unit { 4 | 5 | if n == 0 { 6 | // Do nothing 7 | } 8 | elif n == 1 { 9 | T(q); 10 | } 11 | else { 12 | f(q, n - 1); 13 | f(q, n - 2); 14 | } 15 | } 16 | 17 | 18 | operation T (q : Qubit) : Unit { 19 | body intrinsic; 20 | } 21 | 22 | 23 | operation Test (q : Qubit) : Unit { 24 | 25 | T(q); 26 | T(q); 27 | T(q); 28 | T(q); 29 | T(q); 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestAliasCounts.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | newtype LittleEndian = Qubit[]; 7 | newtype Complex = (Double, Double); 8 | 9 | operation ApplyOp(dummy : Double, coefficients : Complex[], qubits : LittleEndian) : Unit is Adj + Ctl { 10 | } 11 | 12 | operation TestAliasCounts(coefficients : Complex[], qubits : LittleEndian) : Unit is Adj + Ctl { 13 | ApplyOp(0.0, coefficients, qubits); 14 | } 15 | 16 | @EntryPoint() 17 | operation Main() : Unit { 18 | TestAliasCounts([], LittleEndian([])); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestControlled2.ll: -------------------------------------------------------------------------------- 1 | define internal void @Microsoft__Quantum__Intrinsic__K__ctl__wrapper(%Tuple* %capture-tuple, %Tuple* %arg-tuple, %Tuple* %result-tuple) { 2 | entry: 3 | %0 = bitcast %Tuple* %arg-tuple to { %Array*, { %Qubit*, i64 }* }* 4 | %1 = getelementptr inbounds { %Array*, { %Qubit*, i64 }* }, { %Array*, { %Qubit*, i64 }* }* %0, i32 0, i32 0 5 | %2 = getelementptr inbounds { %Array*, { %Qubit*, i64 }* }, { %Array*, { %Qubit*, i64 }* }* %0, i32 0, i32 1 6 | %3 = load %Array*, %Array** %1, align 8 7 | %4 = load { %Qubit*, i64 }*, { %Qubit*, i64 }** %2, align 8 8 | call void @Microsoft__Quantum__Intrinsic__K__ctl(%Array* %3, { %Qubit*, i64 }* %4) 9 | ret void 10 | } 11 | -------------------------------------------------------------------------------- /src/Documentation/Tests.DocGenerator/Utils.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | using Microsoft.Quantum.QsCompiler.DataTypes; 5 | using Microsoft.Quantum.QsCompiler.SyntaxTree; 6 | 7 | namespace Microsoft.Quantum.QsCompiler.Documentation.Testing 8 | { 9 | internal static class Utils 10 | { 11 | internal static readonly QsNullable ZeroLocation = 12 | QsNullable.NewValue(new QsLocation(Position.Zero, Range.Zero)); 13 | 14 | internal static readonly string CanonName = "Microsoft.Quantum.Canon"; 15 | 16 | internal static QsQualifiedName MakeFullName(string name) => new QsQualifiedName(CanonName, name); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.Honeywell.App1/.template.config/template.json.v.template: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/template", 3 | "classifications": ["Common", "Console"], 4 | "name": "Quantum Application Honeywell", 5 | "description": "A project creating a Q# application that can be executed on a Honeywell backend via Azure Quantum.", 6 | "groupIdentity": "Microsoft.Common.Console.Honeywell", 7 | "identity": "Microsoft.Common.Console.QSharp.Honeywell.#MAJOR_VERSION#.#MINOR_VERSION#", 8 | "shortName": "azq-honeywell", 9 | "tags": { 10 | "language": "Q#", 11 | "type": "project" 12 | }, 13 | "sourceName": "Quantum.Honeywell.App1", 14 | "preferNameDirectory": true 15 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestStrings.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | @EntryPoint() 7 | function TestStrings(a : Int, b : Int, arr : Int[]) : String 8 | { 9 | let x = $"a is {a} \\ \r\n"; 10 | let y = $"a+b is {a+b}"; 11 | let z = $"{y}"; 12 | let i = $"Constant double {1.2} bool {true} Pauli {PauliX} Result {One} BigInt {1L} Range {0..3}"; 13 | let data = $"{arr}"; 14 | let res = $"a+b is {x}"; 15 | let defaultArr = new String[1]; 16 | let strArr = ["hello", size = 1]; 17 | return ""; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/ProjectTemplates/Quantum.Quantinuum.App1/.template.config/template.json.v.template: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/template", 3 | "classifications": ["Common", "Console"], 4 | "name": "Quantum Application Quantinuum", 5 | "description": "A project creating a Q# application that can be executed on a Quantinuum backend via Azure Quantum.", 6 | "groupIdentity": "Microsoft.Common.Console.Quantinuum", 7 | "identity": "Microsoft.Common.Console.QSharp.Quantinuum.#MAJOR_VERSION#.#MINOR_VERSION#", 8 | "shortName": "azq-quantinuum", 9 | "tags": { 10 | "language": "Q#", 11 | "type": "project" 12 | }, 13 | "sourceName": "Quantum.Quantinuum.App1", 14 | "preferNameDirectory": true 15 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestArrayLoop.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | function TestArrayLoop (a : (Int, Int)[]) : (Int, Int) 7 | { 8 | mutable (x, y) = (0, 0); 9 | for z in a 10 | { 11 | let (j, k) = z; 12 | set x = x + j; 13 | set y = y + k; 14 | } 15 | 16 | let sizedArr = [3, size = Zero == One ? 1 | 3]; // test for size depending on runtime info 17 | return (x, y); 18 | } 19 | 20 | @EntryPoint() 21 | function Main() : Unit { 22 | let _ = TestArrayLoop([]); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/Trunc.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Integer truncate instruction. 13 | public class Trunc 14 | : Cast 15 | { 16 | internal Trunc(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test16/Lambda.qs: -------------------------------------------------------------------------------- 1 | namespace Test16 { 2 | operation Lambda() : Unit { 3 | let x1 = (x1 -> $"{x1}")(1.0); 4 | 5 | use q1 = Qubit[(x -> x + 1)(1)]; 6 | 7 | use q2 = (Qubit[(x -> x + 1)(1)], Qubit(), Qubit[(x -> x == 1.0 ? 0 | 1)(1.0)]); 8 | 9 | let f1 = (foo) -> foo + 1 + foo; 10 | 11 | let f2 = (foo, bar) -> foo + bar + 1; 12 | 13 | let f3 = foo -> foo + 1; 14 | 15 | for i in (i -> [$"{i}"])(1.0) {} 16 | 17 | if (x -> x or true)(true) { 18 | } elif (y -> y or y or true)(true) { 19 | } elif (y -> y == 1)(1) { 20 | } elif (x -> x + 1)(1) == 2 { 21 | } 22 | 23 | let f4 = (foo, foo) -> foo + foo; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/QsCompiler/TestProjects/test6/test6.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net461;netstandard2.0 4 | x64 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Operation.qs 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestWhile.ll: -------------------------------------------------------------------------------- 1 | define internal i64 @Microsoft__Quantum__Testing__QIR__TestWhile__body(i64 %a, i64 %b) { 2 | entry: 3 | %n = alloca i64, align 8 4 | store i64 %a, i64* %n, align 4 5 | br label %while__1 6 | 7 | while__1: ; preds = %do__1, %entry 8 | %0 = load i64, i64* %n, align 4 9 | %1 = icmp slt i64 %0, %b 10 | br i1 %1, label %do__1, label %wend__1 11 | 12 | do__1: ; preds = %while__1 13 | %2 = mul i64 %0, 2 14 | store i64 %2, i64* %n, align 4 15 | br label %while__1 16 | 17 | wend__1: ; preds = %while__1 18 | %3 = load i64, i64* %n, align 4 19 | ret i64 %3 20 | } 21 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/SignExtend.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Sign extension instruction. 13 | public class SignExtend 14 | : Cast 15 | { 16 | internal SignExtend(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/OptimizerTests/Inlining_input.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /// This namespace contains test cases for operation inlining 5 | namespace Microsoft.Quantum.Testing.Optimization.Inlining { 6 | 7 | operation Test (q : Qubit) : Unit { 8 | f(q, 5); 9 | } 10 | 11 | operation T (q : Qubit) : Unit { 12 | body intrinsic; 13 | } 14 | 15 | operation f (q : Qubit, n : Int) : Unit { 16 | if (n == 0) { 17 | // Do nothing 18 | } 19 | elif (n == 1) { 20 | T(q); 21 | } 22 | else { 23 | f(q, n-1); 24 | f(q, n-2); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/OptimizerTests/LoopUnrolling_input.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | /// This namespace contains test cases for loop unrolling 5 | namespace Microsoft.Quantum.Testing.Optimization.LoopUnrolling { 6 | operation Test () : Int { 7 | using (qs = Qubit[20]) { 8 | for (i in 0..9) { 9 | X(qs[i]); 10 | } 11 | } 12 | 13 | mutable r = 0; 14 | for (i in [0, 2, 4]) { 15 | if (i == 2) { 16 | set r = i + 1; 17 | } 18 | } 19 | return r; 20 | } 21 | 22 | operation X (q : Qubit) : Unit { 23 | body intrinsic; 24 | } 25 | } -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestConditional5.ll: -------------------------------------------------------------------------------- 1 | define internal %Array* @Microsoft__Quantum__Testing__QIR__SlicingWithOpenEndedRange__body(%Array* %arr) { 2 | entry: 3 | call void @__quantum__rt__array_update_alias_count(%Array* %arr, i32 1) 4 | %0 = call i64 @__quantum__rt__array_get_size_1d(%Array* %arr) 5 | %1 = sub i64 %0, 1 6 | %2 = insertvalue %Range { i64 0, i64 2, i64 0 }, i64 %1, 2 7 | %3 = call %Array* @__quantum__rt__array_slice_1d(%Array* %arr, %Range %2, i1 true) 8 | call void @__quantum__rt__array_update_reference_count(%Array* %3, i32 1) 9 | call void @__quantum__rt__array_update_alias_count(%Array* %arr, i32 -1) 10 | call void @__quantum__rt__array_update_reference_count(%Array* %3, i32 -1) 11 | ret %Array* %3 12 | } 13 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestUdtArgument.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | function Build<'T>(build: (Int -> 'T)) : 'T 7 | { 8 | return build(1); 9 | } 10 | 11 | newtype TestType1 = Int; 12 | newtype TestType2 = (Pauli, I : Int); 13 | newtype TestType3 = ((Pauli, I : Int), D : Double); 14 | 15 | @EntryPoint() 16 | operation TestUdtArgument () : (Int, (Pauli, Int)) 17 | { 18 | let udt1 = Build(TestType1); 19 | let udt2 = Build(TestType2(PauliX, _)); 20 | let udt3 = Build(TestType3((PauliX, _), 2.0)); 21 | return (udt1!, udt2!); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/MemMove.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Intrinsic call to target optimized memmove. 13 | public class MemMove 14 | : MemIntrinsic 15 | { 16 | internal MemMove(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/UIToFP.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Instruction to cast an unsigned integer to a float. 13 | public class UIToFP 14 | : Cast 15 | { 16 | internal UIToFP(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/ZeroExtend.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Instruction to zero extend a value. 13 | public class ZeroExtend 14 | : Cast 15 | { 16 | internal ZeroExtend(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Values/ConstantData.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Values 11 | { 12 | /// Base class for constants with no operands. 13 | public class ConstantData 14 | : Constant 15 | { 16 | internal ConstantData(LLVMValueRef handle) 17 | : base(handle) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestEntryPoint.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR { 5 | 6 | @EntryPoint() 7 | operation TestEntryPoint( 8 | arr : Pauli[], str : String, res : Result, range : Range, (cnt : Int, b : Bool)) 9 | : (Pauli[], String, Result, Range, (Int, Bool)) { 10 | 11 | mutable sum = 0.0; 12 | mutable flag = b; 13 | for pauli in arr 14 | { 15 | let value = pauli == PauliI ? 0. | 1.; 16 | set sum = sum + (flag ? value | -value); 17 | set flag = not flag; 18 | } 19 | 20 | return (arr, str, res, range, (cnt, b)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/DebugInfo/DINode.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.DebugInfo 11 | { 12 | /// Root of the object hierarchy for Debug information metadata nodes 13 | public class DINode 14 | : MDNode 15 | { 16 | internal DINode(LLVMMetadataRef handle) 17 | : base(handle) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/MemSet.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Instruction for the LLVM intrinsic memset function. 13 | public class MemSet 14 | : MemIntrinsic 15 | { 16 | internal MemSet(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/BitCast.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// This class represents a no-op cast from one type to another. 13 | public class BitCast 14 | : Cast 15 | { 16 | internal BitCast(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/MemCpy.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Instruction for the LLVM intrinsic llvm.memcpy instruction. 13 | public class MemCpy 14 | : MemIntrinsic 15 | { 16 | internal MemCpy(LLVMValueRef handle) 17 | : base(handle) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/ReturnInstruction.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Return instruction. 13 | public class ReturnInstruction 14 | : Terminator 15 | { 16 | internal ReturnInstruction(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/SelectInstruction.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Select instruction. 13 | public class SelectInstruction 14 | : Instruction 15 | { 16 | internal SelectInstruction(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/Terminator.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Base class for all terminator instructions. 13 | public class Terminator 14 | : Instruction 15 | { 16 | internal Terminator(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/UnaryOperator.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Base class for a unary operator. 13 | public class UnaryOperator 14 | : Instruction 15 | { 16 | internal UnaryOperator(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/RoslynWrapper/CodeGenerator.fs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.RoslynWrapper 2 | 3 | /// 4 | /// This is the entry point to the Roslyn Wrapper. 5 | /// Pass a to to get string with the generated code. 6 | /// 7 | [] 8 | module CodeGenerator = 9 | 10 | open Microsoft.CodeAnalysis 11 | open Microsoft.CodeAnalysis.CSharp 12 | open Microsoft.CodeAnalysis.CSharp.Syntax 13 | 14 | let generateCodeToString (cu: CompilationUnitSyntax) = 15 | let fn = Formatting.Formatter.Format(cu, new AdhocWorkspace()) 16 | let sb = new System.Text.StringBuilder() 17 | use sw = new System.IO.StringWriter(sb) 18 | fn.WriteTo(sw) 19 | sb.ToString() 20 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/DebugInfo/DILexicalBlockBase.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.DebugInfo 11 | { 12 | /// Base for lexical blocks 13 | public class DILexicalBlockBase 14 | : DILocalScope 15 | { 16 | internal DILexicalBlockBase(LLVMMetadataRef handle) 17 | : base(handle) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/DebugInfo/DIMacroNode.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.DebugInfo 11 | { 12 | /// Base class for macro related nodes in the debug hierarchy 13 | public class DIMacroNode 14 | : MDNode 15 | { 16 | internal DIMacroNode(LLVMMetadataRef handle) 17 | : base(handle) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/BinaryOperator.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Base class for a binary operator. 13 | public class BinaryOperator 14 | : Instruction 15 | { 16 | internal BinaryOperator(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/MemIntrinsic.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Base class for memory intrinsic instructions. 13 | public class MemIntrinsic 14 | : Intrinsic 15 | { 16 | internal MemIntrinsic(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/PointerToInt.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Instruction to cast a pointer to an integer value. 13 | public class PointerToInt 14 | : Cast 15 | { 16 | internal PointerToInt(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/Unreachable.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Instruction to indicate an unreachable location. 13 | public class Unreachable 14 | : Terminator 15 | { 16 | internal Unreachable(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Values/ConstantDataArray.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Values 11 | { 12 | /// Array of constant data. 13 | public class ConstantDataArray 14 | : ConstantDataSequential 15 | { 16 | internal ConstantDataArray(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/SIToFP.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Instruction for converting a signed integer value into a floating point value. 13 | public class SIToFP 14 | : Cast 15 | { 16 | internal SIToFP(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/ShuffleVector.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Instruction to shuffle the elements of a vector. 13 | public class ShuffleVector 14 | : Instruction 15 | { 16 | internal ShuffleVector(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Values/ConstantAggregate.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Values 11 | { 12 | /// Base class for aggregate constants (with operands). 13 | public class ConstantAggregate 14 | : Constant 15 | { 16 | internal ConstantAggregate(LLVMValueRef handle) 17 | : base(handle) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/QirGeneration/QirGeneration.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 10.0 6 | Microsoft.Quantum.QsCompiler.QirGeneration 7 | Microsoft.Quantum.QirGeneration 8 | 9 | true 10 | annotations 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/UnaryInstruction.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Base class for unary operator instructions. 13 | public class UnaryInstruction 14 | : Instruction 15 | { 16 | internal UnaryInstruction(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/VAArg.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Instruction to load an argument of a specified type from a variadic argument list. 13 | public class VaArg 14 | : UnaryInstruction 15 | { 16 | internal VaArg(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/TestTargets/Libraries/Library1/AccessModifiers.qs: -------------------------------------------------------------------------------- 1 | /// This file contains redefinitions of types and callables declared in Tests.Compiler\TestCases\AccessModifiers.qs. It 2 | /// is used as an assembly reference to test support for re-using names of inaccessible declarations in references. 3 | namespace Microsoft.Quantum.Testing.AccessModifiers { 4 | internal newtype InternalType = Unit; 5 | 6 | internal function InternalFunction () : Unit {} 7 | } 8 | 9 | /// This namespace contains additional definitions of types and callables meant to be used by the 10 | /// Microsoft.Quantum.Testing.AccessModifiers namespace. 11 | namespace Microsoft.Quantum.Testing.AccessModifiers.C { 12 | internal newtype InternalTypeC = Unit; 13 | 14 | internal function InternalFunctionC () : Unit {} 15 | } 16 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestBigInts.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | function TestBigInts (a : BigInt, b : BigInt) : BigInt 7 | { 8 | let c = a > b ? a | b; 9 | let d = c * a - b / 7L; 10 | let e = d >>> 3; 11 | let f = d ^ 5; 12 | let g = (e &&& f) ||| 0xffffL; 13 | return ~~~g; 14 | } 15 | 16 | @EntryPoint() 17 | function Main() : Unit { 18 | let _ = TestBigInts(0L, 0L); 19 | let N1 = 12345L; 20 | let N2 = 1522605027922533360535618378132637429718068114961380688657908494580122963258952897654000350692006139L; 21 | let _ = TestBigInts(N1, N2); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestForLoop.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR { 5 | 6 | newtype Energy = (Abs : Double, Name : String); 7 | 8 | function TestNestedLoops () : Energy { 9 | 10 | let name = "energy"; 11 | mutable res = Energy(0.0, ""); 12 | set res w/= Name <- name; 13 | 14 | mutable energy = 0.0; 15 | 16 | for _ in 0 .. 10 { 17 | for j in 5 .. -1 .. 0 { 18 | set energy += 0.5; 19 | } 20 | } 21 | 22 | return res w/ Abs <- energy; 23 | } 24 | 25 | @EntryPoint() 26 | function Main() : Unit { 27 | let _ = TestNestedLoops(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/VSCodeExtension/src/sanitize-namespace-name.ts: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | export function sanitizeNamespaceName(projectName: string): string { 5 | // Replace non-alphanumeric characters, except for dots, with underscores. 6 | let namespaceName = projectName.replace(/[^A-Za-z0-9_.]/g, "_"); 7 | 8 | // Replace illegal character combinations in the namespace name. 9 | namespaceName = namespaceName.replace(/_\./g, "."); 10 | namespaceName = namespaceName.replace(/\.+/g, "."); 11 | namespaceName = namespaceName.replace(/_+/g, "_"); 12 | if (namespaceName.endsWith("_")) { 13 | namespaceName = namespaceName.substring(0, namespaceName.length - 1); 14 | } 15 | return namespaceName; 16 | } 17 | -------------------------------------------------------------------------------- /src/Telemetry/Build/test-coverage.ps1: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. 2 | # Licensed under the MIT License. 3 | 4 | Push-Location $PSScriptRoot/../ 5 | 6 | dotnet test --collect:"XPlat Code Coverage" 7 | 8 | $coverageFile = (Get-ChildItem $PSScriptRoot/../Tests/TestResults/*/coverage.cobertura.xml -Recurse | 9 | Sort-Object -pro LastWriteTime -Descending | 10 | Select -First 1).FullName 11 | 12 | Push-Location $PSScriptRoot/../Tests/ 13 | dotnet reportgenerator "-reports:$coverageFile" "-targetdir:TestResults/html" -reporttypes:HTML; 14 | Pop-Location 15 | 16 | $reportFile = Resolve-Path "$PSScriptRoot/../Tests/TestResults/html/index.htm" 17 | 18 | Write-Output "Attempting to open: file:///$reportFile" 19 | 20 | Start-Process "file:///$reportFile" 21 | 22 | Pop-Location 23 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.CSharpGeneration/Circuits/LineNumbers.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Tests.LineNumbers { 5 | 6 | open Microsoft.Quantum.Intrinsic; 7 | 8 | 9 | operation TestLineInBlocks (n : Int) : Result { 10 | 11 | let r = n + 1; 12 | 13 | using ((ctrls, q) = (Qubit[r], Qubit())) { 14 | 15 | if (n == 0) { 16 | X(q); 17 | } 18 | else { 19 | 20 | for (c in ctrls[0 .. 2 .. r]) { 21 | Controlled X([c], q); 22 | } 23 | } 24 | } 25 | 26 | return Zero; 27 | } 28 | 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Extensions/LLVMMemoryBufferRefExtensions.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 3 | // Portions Copyright (c) Microsoft Corporation 4 | // 5 | 6 | using System; 7 | 8 | namespace LlvmBindings.Interop 9 | { 10 | /// Extensions for . 11 | public static unsafe class LLVMMemoryBufferRefExtensions 12 | { 13 | /// Convenience wrapper for . 14 | public static void Close(this LLVMMemoryBufferRef self) 15 | { 16 | LLVM.DisposeMemoryBuffer(self); 17 | self.Handle = default; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Metadata/ValueAsMetadata.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings 11 | { 12 | /// Used to wrap an in the Metadata hierarchy 13 | public class ValueAsMetadata 14 | : LlvmMetadata 15 | { 16 | private protected ValueAsMetadata(LLVMMetadataRef handle) 17 | : base(handle) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.github/workflows/devskim.yml: -------------------------------------------------------------------------------- 1 | name: DevSkim 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | workflow_dispatch: 9 | schedule: 10 | # set schedule to run at 2AM PT on Saturdays 11 | - cron: '0 9 * * Sat' 12 | 13 | jobs: 14 | lint: 15 | name: DevSkim 16 | runs-on: ubuntu-latest 17 | permissions: 18 | actions: read 19 | contents: read 20 | security-events: write 21 | steps: 22 | - name: Checkout code 23 | uses: actions/checkout@v3 24 | 25 | - name: Run DevSkim scanner 26 | uses: microsoft/DevSkim-Action@v1 27 | 28 | - name: Upload DevSkim scan results to GitHub Security tab 29 | uses: github/codeql-action/upload-sarif@v2 30 | with: 31 | sarif_file: devskim-results.sarif 32 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/UserOp2.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Custom operator that can be used in LLVM transform passes but should be removed before target instruction selection. 13 | public class UserOp2 : Instruction 14 | { 15 | internal UserOp2(LLVMValueRef valueRef) 16 | : base(valueRef) 17 | { 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Metadata/ConstantAsMetadata.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | using LlvmBindings.Values; 10 | 11 | namespace LlvmBindings 12 | { 13 | /// Constant as metadata 14 | public class ConstantAsMetadata 15 | : ValueAsMetadata 16 | { 17 | internal ConstantAsMetadata(LLVMMetadataRef handle) 18 | : base(handle) 19 | { 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/DebugInfoIntrinsic.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Base class for debug information intrinsic functions in LLVM IR. 13 | public class DebugInfoIntrinsic 14 | : Intrinsic 15 | { 16 | internal DebugInfoIntrinsic(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Metadata/MDTuple.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings 11 | { 12 | /// Tuple of Metadata nodes 13 | /// 14 | /// This acts as a container of nodes in the metadata hierarchy 15 | /// 16 | public class MDTuple : MDNode 17 | { 18 | internal MDTuple(LLVMMetadataRef handle) 19 | : base(handle) 20 | { 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestUsing.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | operation ArbitraryAllocation (max : Int, q : Qubit) : Unit { 7 | using ((a, (b, c), d) = (Qubit(), (Qubit[max], Qubit()), Qubit[2])) { 8 | 9 | let x = b[1]; 10 | borrowing (z = Qubit()) { 11 | 12 | let y = b[0..2..max]; 13 | if (Length(y) == max) { 14 | return (); 15 | } 16 | } 17 | } 18 | } 19 | 20 | @EntryPoint() 21 | operation TestUsing() : Unit 22 | { 23 | using (q = Qubit()) 24 | { 25 | ArbitraryAllocation(3, q); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/QuantumSdk/Tools/BuildConfiguration/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | using CommandLine; 5 | 6 | namespace Microsoft.Quantum.Sdk.Tools 7 | { 8 | public static partial class BuildConfiguration 9 | { 10 | public enum ReturnCode 11 | { 12 | SUCCESS = 0, 13 | MISSING_ARGUMENTS = 1, 14 | INVALID_ARGUMENTS = 2, 15 | IO_EXCEPTION = 3, 16 | UNEXPECTED_ERROR = 100, 17 | } 18 | 19 | private static int Main(string[] args) => 20 | Parser.Default 21 | .ParseArguments(args) 22 | .MapResult( 23 | (Options opts) => (int)Generate(opts), 24 | errs => (int)ReturnCode.INVALID_ARGUMENTS); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/UserOp1.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Custom operator that can be used in LLVM transform passes but should be removed before target instruction selection. 13 | public class UserOp1 14 | : Instruction 15 | { 16 | internal UserOp1(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsFmt/Formatter/ParseTree/Namespace.fsi: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.QsFmt.Formatter.ParseTree 5 | 6 | open System.Collections.Immutable 7 | open Antlr4.Runtime 8 | open Microsoft.Quantum.QsFmt.Formatter.SyntaxTree 9 | open Microsoft.Quantum.QsFmt.Parser 10 | 11 | /// 12 | /// Constructors for syntax tree and nodes. 13 | /// 14 | module internal Namespace = 15 | /// 16 | /// Creates a syntax tree node from the parse tree 17 | /// node and the list of . 18 | /// 19 | val toDocument: tokens: IToken ImmutableArray -> context: QSharpParser.DocumentContext -> Document 20 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/DebugInfo/DIExpression.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.DebugInfo 11 | { 12 | /// Debug information expression 13 | /// LLVM DIExpression 14 | public class DIExpression 15 | : MDNode 16 | { 17 | internal DIExpression(LLVMMetadataRef handle) 18 | : base(handle) 19 | { 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/IntCmp.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Instruction to perform an integer compare. 13 | /// LLVM intcmp Instruction 14 | public class IntCmp 15 | : Cmp 16 | { 17 | internal IntCmp(LLVMValueRef valueRef) 18 | : base(valueRef) 19 | { 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/QsCompiler/RoslynWrapper/Invocation.fs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Quantum.RoslynWrapper 2 | 3 | #nowarn "1182" // Unused parameters 4 | 5 | /// 6 | /// Use this module to specify the syntax for a method invocations 7 | /// 8 | [] 9 | module Invocation = 10 | open Microsoft.CodeAnalysis 11 | open Microsoft.CodeAnalysis.CSharp 12 | open Microsoft.CodeAnalysis.CSharp.Syntax 13 | 14 | let private setArguments (methodArguments: ArgumentSyntax seq) (ie: InvocationExpressionSyntax) = 15 | methodArguments 16 | |> (SyntaxFactory.SeparatedList >> SyntaxFactory.ArgumentList) 17 | |> ie.WithArgumentList 18 | 19 | let ``invoke`` m ``(`` args ``)`` = 20 | m |> SyntaxFactory.InvocationExpression |> setArguments (args |> Seq.map SyntaxFactory.Argument) 21 | :> ExpressionSyntax 22 | -------------------------------------------------------------------------------- /.github/workflows/qdk-sync.yml: -------------------------------------------------------------------------------- 1 | name: Sync QDK repos 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | sync-repos: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Login to Azure 13 | uses: Azure/login@v1 14 | with: 15 | creds: ${{ secrets.AZURE_CREDENTIALS }} 16 | 17 | - id: AzureKeyVault 18 | uses: Azure/get-keyvault-secrets@v1 19 | with: 20 | keyvault: 'kv-qdk-build' 21 | secrets: 'qdkBuildPAT' 22 | 23 | - name: 'Trigger QDK sync build' 24 | uses: Azure/pipelines@releases/v1 25 | with: 26 | azure-devops-project-url: 'https://dev.azure.com/ms-quantum-public/Microsoft Quantum (public)' 27 | azure-pipeline-name: 'microsoft.qdk.sync' 28 | azure-devops-token: ${{ steps.AzureKeyVault.outputs.qdkBuildPAT }} 29 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/FCmp.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Instruction to perform comparison of floating point values. 13 | /// LLVM fcmp Instruction 14 | public class FCmp 15 | : Cmp 16 | { 17 | internal FCmp(LLVMValueRef valueRef) 18 | : base(valueRef) 19 | { 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.CSharpGeneration/Circuits/UnitTests.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Core { 5 | 6 | @Attribute() 7 | newtype Attribute = Unit; 8 | } 9 | 10 | namespace Microsoft.Quantum.Diagnostics { 11 | 12 | @Attribute() 13 | newtype Test = String; 14 | } 15 | 16 | namespace Microsoft.Quantum.Tests.UnitTests { 17 | 18 | open Microsoft.Quantum.Diagnostics; 19 | 20 | @Test("QuantumSimulator") 21 | @Test("ToffoliSimulator") 22 | operation UnitTest1 () : Unit { 23 | } 24 | 25 | @Test("SomeNamespace.CustomSimulator") 26 | operation UnitTest2() : Unit { 27 | } 28 | 29 | @Test("QuantumSimulator") 30 | @Test("SparseSimulator") 31 | operation UnitTest3 () : Unit { 32 | } 33 | } 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/QsCompiler/Tests.Compiler/TestCases/QirTests/TestDeclarations.qs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace Microsoft.Quantum.Testing.QIR 5 | { 6 | operation SelfAdjointIntrinsic() : Unit 7 | is Adj + Ctl { 8 | body intrinsic; 9 | adjoint self; 10 | } 11 | 12 | operation SelfAdjointOp() : Unit 13 | is Adj + Ctl { 14 | body (...) { } 15 | adjoint self; 16 | } 17 | 18 | @EntryPoint() 19 | operation TestDeclarations () : Unit { 20 | using (q = Qubit()) { 21 | 22 | Adjoint SelfAdjointIntrinsic(); 23 | Controlled Adjoint SelfAdjointIntrinsic([q], ()); 24 | 25 | Adjoint SelfAdjointOp(); 26 | Controlled Adjoint SelfAdjointOp([q], ()); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/DebugInfo/DILexicalBlock.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.DebugInfo 11 | { 12 | /// Debug information for a Lexical block 13 | /// LLVM DILexicalBlock 14 | public class DILexicalBlock 15 | : DILexicalBlockBase 16 | { 17 | internal DILexicalBlock(LLVMMetadataRef handle) 18 | : base(handle) 19 | { 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/AddressSpaceCast.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Address space cast instruction. 13 | /// LLVM addrspacecast .. to 14 | public class AddressSpaceCast : Cast 15 | { 16 | internal AddressSpaceCast(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/FPExt.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Extends a floating point value to a larger floating point value. 13 | /// LLVM fpext .. to instruction 14 | public class FPExt 15 | : Cast 16 | { 17 | internal FPExt(LLVMValueRef valueRef) 18 | : base(valueRef) 19 | { 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/QsCompiler/LlvmBindings/Instructions/FPToUI.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Ubiquity.NET Contributors. All rights reserved. 4 | // Portions Copyright (c) Microsoft Corporation 5 | // 6 | // ----------------------------------------------------------------------- 7 | 8 | using LlvmBindings.Interop; 9 | 10 | namespace LlvmBindings.Instructions 11 | { 12 | /// Instruction to convert a floating point value to an unsigned integer type. 13 | /// LLVM fptoui .. to Instruction 14 | public class FPToUI : Cast 15 | { 16 | internal FPToUI(LLVMValueRef valueRef) 17 | : base(valueRef) 18 | { 19 | } 20 | } 21 | } 22 | --------------------------------------------------------------------------------