Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/QsCompiler/CompilationManager/AssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,18 @@ public static bool LoadSyntaxTree(
}

/// <summary>
/// Loads any QIR byte code included as a resource from <paramref name="assemblyFileInfo"/>.
/// Loads any QIR bitcode included as a resource from <paramref name="assemblyFileInfo"/>.
/// </summary>
/// <param name="assemblyFileInfo">The file info of a .NET DLL from which to load the QIR byte code.</param>
/// <param name="qirByteStream">A stream to store the QIR byte code embedded to<paramref name="assemblyFileInfo"/> as a resource.</param>
/// <param name="assemblyFileInfo">The file info of a .NET DLL from which to load the QIR bitcode.</param>
/// <param name="qirStream">A stream to store the QIR bitcode embedded to<paramref name="assemblyFileInfo"/> as a resource.</param>
/// <returns>
/// True if <paramref name="assemblyFileInfo"/> includes the QIR byte code resource, false otherwise.
/// True if <paramref name="assemblyFileInfo"/> includes the QIR bitcode resource, false otherwise.
/// </returns>
/// <exception cref="FileNotFoundException"><paramref name="assemblyFileInfo"/> does not exist.</exception>
public static bool LoadQirByteCode(FileInfo assemblyFileInfo, Stream qirByteStream)
public static bool LoadQirBitcode(FileInfo assemblyFileInfo, Stream qirStream)
{
using var assemblyFile = GetAssemblyReader(assemblyFileInfo.FullName);
return LoadResource(DotnetCoreDll.ResourceNameQsDataQirV1, assemblyFile, qirByteStream);
return LoadResource(DotnetCoreDll.ResourceNameQsDataQirV1, assemblyFile, qirStream);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/QsCompiler/Compiler/RewriteSteps/SyntaxTreeTrimming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal class SyntaxTreeTrimming : IRewriteStep
public bool ImplementsPostconditionVerification => false;

/// <summary>
/// Constructor for the SyntaxTreeTrimming Rewrite Step.
/// Initializes a new instance of the <see cref="SyntaxTreeTrimming"/> class.
/// </summary>
/// <param name="keepAllIntrinsics">When true, intrinsics will not be removed as part of the rewrite step.</param>
public SyntaxTreeTrimming(bool keepAllIntrinsics = true, IEnumerable<QsQualifiedName>? dependencies = null)
Expand Down
12 changes: 0 additions & 12 deletions src/QsCompiler/LlvmBindings/BitcodeModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,18 +326,6 @@ public bool Verify(out string errorMessage)
return this.moduleHandle.TryVerify(LLVMVerifierFailureAction.LLVMReturnStatusAction, out errorMessage);
}

/// <summary>Gets a function by name from this module.</summary>
/// <param name="name">Name of the function to get.</param>
/// <returns>The function or default if not found.</returns>
[Obsolete("Use TryGetFunction instead")]
public IrFunction? GetFunction(string name)
{
this.ThrowIfDisposed();

var funcRef = this.moduleHandle.GetNamedFunction(name);
return funcRef == default ? default : Value.FromHandle<IrFunction>(funcRef);
}

/// <summary>Looks up a function in the module by name.</summary>
/// <param name="name">Name of the function.</param>
/// <param name="function">The function or <see langword="default"/> if not found.</param>
Expand Down
20 changes: 20 additions & 0 deletions src/QsCompiler/QirGeneration/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,26 @@ private static string UniqueName(string name, Dictionary<string, int> names)
return $"{name}__{index}";
}

/// <inheritdoc cref="NameGeneration.InteropFriendlyWrapperName(QsQualifiedName)"/>
[Obsolete("Please use NameGeneration.InteropFriendlyWrapperName instead.", true)]
public static string InteropFriendlyWrapperName(QsQualifiedName fullName) =>
NameGeneration.InteropFriendlyWrapperName(fullName);

/// <inheritdoc cref="NameGeneration.EntryPointName(QsQualifiedName)"/>
[Obsolete("Please use NameGeneration.EntryPointName instead.", true)]
public static string EntryPointName(QsQualifiedName fullName) =>
NameGeneration.EntryPointName(fullName);

/// <inheritdoc cref="NameGeneration.FunctionName(QsQualifiedName, QsSpecializationKind)"/>
[Obsolete("Please use NameGeneration.FunctionName instead.", true)]
public static string FunctionName(QsQualifiedName fullName, QsSpecializationKind kind) =>
NameGeneration.FunctionName(fullName, kind);

/// <inheritdoc cref="NameGeneration.FunctionWrapperName(QsQualifiedName, QsSpecializationKind)"/>
[Obsolete("Please use NameGeneration.FunctionWrapperName instead.", true)]
public static string FunctionWrapperName(QsQualifiedName fullName, QsSpecializationKind kind) =>
NameGeneration.FunctionWrapperName(fullName, kind);

/// <summary>
/// Order of specializations in the constant array that contains the fours IrFunctions
/// associated with a callable.
Expand Down
92 changes: 0 additions & 92 deletions src/QsCompiler/QirGeneration/EntryPointOperationLoader.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/QsCompiler/QirGeneration/NameGeneration.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Quantum.QsCompiler.SyntaxTree;
using Microsoft.Quantum.QsCompiler.Transformations.Targeting;
Expand Down Expand Up @@ -73,15 +72,5 @@ internal static bool TryGetTargetInstructionName(QsCallable callable, [MaybeNull
return false;
}
}

/// <summary>
/// Order of specializations in the constant array that contains the fours IrFunctions
/// associated with a callable.
/// </summary>
public static readonly ImmutableArray<QsSpecializationKind> FunctionArray = ImmutableArray.Create(
QsSpecializationKind.QsBody,
QsSpecializationKind.QsAdjoint,
QsSpecializationKind.QsControlled,
QsSpecializationKind.QsControlledAdjoint);
}
}
9 changes: 9 additions & 0 deletions src/QsCompiler/Transformations/MonomorphizationValidation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@

namespace Microsoft.Quantum.QsCompiler.Transformations.Monomorphization.Validation
{
/// <summary>
/// Validates that the monomorphization transformation has removed all references to
/// generic objects.
/// </summary>
public class ValidateMonomorphization : SyntaxTreeTransformation<ValidateMonomorphization.TransformationState>
{
/// <summary>
/// Applies the transformation that walks through the syntax tree, checking to ensure
/// that all generic data has been removed. If allowTypeParametersForIntrinsics is true,
/// then generic data is allowed for type parameters of callables that have an intrinsic body.
/// </summary>
public static void Apply(QsCompilation compilation, bool allowTypeParametersForIntrinsics = true)
{
var intrinsicCallableSet = allowTypeParametersForIntrinsics
Expand Down
15 changes: 15 additions & 0 deletions src/QsCompiler/Transformations/SyntaxTreeTrimming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@

namespace Microsoft.Quantum.QsCompiler.Transformations.SyntaxTreeTrimming
{
/// <summary>
/// Removes unused callables from the syntax tree.
/// </summary>
public static class TrimSyntaxTree
{
/// <summary>
/// Applies the transformation that removes from the syntax tree all callables that
/// are unused, meaning they are not a descendant of at least one entry point in
/// the call graph. If keepAllIntrinsics is true, callables with an intrinsic body
/// will not be trimmed, regardless of usage. Any callables that later
/// transformations will depend on should be passed in and will not be trimmed,
/// regardless of usage. Note that unused type constructors will be subject to
/// trimming as any other callable.
/// </summary>
public static QsCompilation Apply(QsCompilation compilation, bool keepAllIntrinsics, IEnumerable<QsQualifiedName>? dependencies = null)
{
return TrimTree.Apply(compilation, keepAllIntrinsics, dependencies);
Expand Down Expand Up @@ -68,6 +80,9 @@ private static bool Filter(QsNamespaceElement elem, ImmutableHashSet<QsQualified
}
}

/// <summary>
/// Class representing the state of the transformation.
/// </summary>
public class TransformationState
{
public Func<QsNamespaceElement, bool> NamespaceElementFilter { get; }
Expand Down