Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
2 changes: 1 addition & 1 deletion src/Passes/Source/AllocationManager/IAllocationManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include "Types/Types.hpp"
#include "QatTypes/QatTypes.hpp"

#include <memory>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion src/Passes/Source/Apps/Qat/QatConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Licensed under the MIT License.

#include "Commandline/ConfigurationManager.hpp"
#include "Types/Types.hpp"
#include "QatTypes/QatTypes.hpp"

namespace microsoft
{
Expand Down
2 changes: 1 addition & 1 deletion src/Passes/Source/Commandline/ConfigurationManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Commandline/ConfigBind.hpp"
#include "Commandline/IConfigBind.hpp"
#include "Commandline/ParameterParser.hpp"
#include "Types/Types.hpp"
#include "QatTypes/QatTypes.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
2 changes: 1 addition & 1 deletion src/Passes/Source/Commandline/IConfigBind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Licensed under the MIT License.

#include "Commandline/ParameterParser.hpp"
#include "Types/Types.hpp"
#include "QatTypes/QatTypes.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
2 changes: 1 addition & 1 deletion src/Passes/Source/Commandline/ParameterParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include "Types/Types.hpp"
#include "QatTypes/QatTypes.hpp"

#include <string>
#include <unordered_map>
Expand Down
2 changes: 1 addition & 1 deletion src/Passes/Source/Generators/ProfileGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "Commandline/ConfigurationManager.hpp"
#include "Profile/Profile.hpp"
#include "Types/Types.hpp"
#include "QatTypes/QatTypes.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
2 changes: 1 addition & 1 deletion src/Passes/Source/Logging/ILogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include "Types/Types.hpp"
#include "QatTypes/QatTypes.hpp"

#include <cstdint>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion src/Passes/Source/ModuleLoader/ModuleLoader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include "QatTypes/QatTypes.hpp"
#include "RemoveDisallowedAttributesPass/RemoveDisallowedAttributesPass.hpp"
#include "Types/Types.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
2 changes: 1 addition & 1 deletion src/Passes/Source/Profile/Profile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "AllocationManager/AllocationManager.hpp"
#include "AllocationManager/IAllocationManager.hpp"
#include "Types/Types.hpp"
#include "QatTypes/QatTypes.hpp"
#include "Validator/Validator.hpp"

#include "Llvm/Llvm.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include "Types/Types.hpp"
#include "QatTypes/QatTypes.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
2 changes: 1 addition & 1 deletion src/Passes/Source/Rules/Factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#include "AllocationManager/AllocationManager.hpp"
#include "Commandline/ConfigurationManager.hpp"
#include "QatTypes/QatTypes.hpp"
#include "Rules/FactoryConfig.hpp"
#include "Rules/ReplacementRule.hpp"
#include "Rules/RuleSet.hpp"
#include "Types/Types.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
2 changes: 1 addition & 1 deletion src/Passes/Source/Rules/Notation/BasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/Patterns/Instruction.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
6 changes: 3 additions & 3 deletions src/Passes/Source/Rules/Notation/BitCast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.

#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/Any.hpp"
#include "Rules/Operands/Call.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/Patterns/AnyPattern.hpp"
#include "Rules/Patterns/CallPattern.hpp"
#include "Rules/Patterns/Instruction.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
6 changes: 3 additions & 3 deletions src/Passes/Source/Rules/Notation/Branch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.

#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/Any.hpp"
#include "Rules/Operands/Call.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/Patterns/AnyPattern.hpp"
#include "Rules/Patterns/CallPattern.hpp"
#include "Rules/Patterns/Instruction.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
64 changes: 64 additions & 0 deletions src/Passes/Source/Rules/Notation/Call.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#pragma once
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

/// @defgroup shorthandNotation Shorthand Notation

#include "Rules/IOperandPrototype.hpp"

#include "Llvm/Llvm.hpp"

#include <unordered_map>
#include <vector>

namespace microsoft
{
namespace quantum
{
namespace notation
{

using IOperandPrototypePtr = std::shared_ptr<IOperandPrototype>;

/// Shorthand notations are made to make it possible to match patterns in the QIR. This part of the
/// library focuses on making it easy to express advance patterns in just a few lines and specify
/// what parts of the IR is of interest to the replacer function. An example is following pattern
///
/// ```
/// auto get_one = call("__quantum__rt__result_get_one");
/// addRule(
/// {branch("cond"_cap = call("__quantum__rt__result_equal", "result"_cap = _, "one"_cap =
/// get_one), _, _),
/// replace_branch_positive});
///
/// ```
///
/// which matches IRs of the form
///
/// ```
/// %1 = call %Result* @__quantum__rt__result_get_one()
/// %2 = call i1 @__quantum__rt__result_equal(%Result* %0, %Result* %1)
/// br i1 %2, label %then0__1, label %continue__1
/// ```
///
/// The pattern futher specifies that as a successful match is obtained, a table capturing
/// certain values must be created. In the above example, the table would contain three
/// entries: `cond`, `result` and `one` each of which would point to a a llvm::Value*
/// in the QIR. This allows the replacement function to easily manipulate the DAG in these
/// three places (four if you include the main captured value which is always passed to the
/// replacement function).

/// Shorthand notation to match an instruction for a function call.
/// The resulting IOperandPrototype matches a function call with arguments
/// as specified by the arguments given. For instance,
///
/// ```
/// addRule({call("foo", _, _), deleteInstruction()});
/// ```
///
/// matches a call to the function `foo` with exactly two arguments.
template <typename... Args> IOperandPrototypePtr call(std::string const& name, Args... args);

} // namespace notation
} // namespace quantum
} // namespace microsoft
7 changes: 2 additions & 5 deletions src/Passes/Source/Rules/Notation/Call.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
// Licensed under the MIT License.

#include "Llvm/Llvm.hpp"
#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/Any.hpp"
#include "Rules/Operands/Call.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/ReplacementRule.hpp"
#include "Rules/Patterns/AnyPattern.hpp"
#include "Rules/Patterns/CallPattern.hpp"

#include <unordered_map>
#include <vector>
Expand Down
6 changes: 3 additions & 3 deletions src/Passes/Source/Rules/Notation/CallByNameOnly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.

#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/Any.hpp"
#include "Rules/Operands/Call.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/Patterns/AnyPattern.hpp"
#include "Rules/Patterns/CallPattern.hpp"
#include "Rules/Patterns/Instruction.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
6 changes: 3 additions & 3 deletions src/Passes/Source/Rules/Notation/Capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.

#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/Any.hpp"
#include "Rules/Operands/Call.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/Patterns/AnyPattern.hpp"
#include "Rules/Patterns/CallPattern.hpp"
#include "Rules/Patterns/Instruction.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
6 changes: 3 additions & 3 deletions src/Passes/Source/Rules/Notation/ConstInt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.

#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/Any.hpp"
#include "Rules/Operands/Call.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/Patterns/AnyPattern.hpp"
#include "Rules/Patterns/CallPattern.hpp"
#include "Rules/Patterns/Instruction.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
6 changes: 3 additions & 3 deletions src/Passes/Source/Rules/Notation/IntToPtr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.

#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/Any.hpp"
#include "Rules/Operands/Call.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/Patterns/AnyPattern.hpp"
#include "Rules/Patterns/CallPattern.hpp"
#include "Rules/Patterns/Instruction.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
6 changes: 3 additions & 3 deletions src/Passes/Source/Rules/Notation/Load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.

#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/Any.hpp"
#include "Rules/Operands/Call.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/Patterns/AnyPattern.hpp"
#include "Rules/Patterns/CallPattern.hpp"
#include "Rules/Patterns/Instruction.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
6 changes: 3 additions & 3 deletions src/Passes/Source/Rules/Notation/Notation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.

#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/Any.hpp"
#include "Rules/Operands/Call.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/Patterns/AnyPattern.hpp"
#include "Rules/Patterns/CallPattern.hpp"
#include "Rules/Patterns/Instruction.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
9 changes: 5 additions & 4 deletions src/Passes/Source/Rules/Notation/Notation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

/// @defgroup shorthandNotation Shorthand Notation

#include "Rules/Notation/Call.hpp"
#include "Rules/Notation/Call.ipp"
#include "Rules/Notation/Phi.ipp"
#include "Rules/Operands/Any.hpp"
#include "Rules/Operands/Call.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/Operands/Phi.hpp"
#include "Rules/Patterns/AnyPattern.hpp"
#include "Rules/Patterns/CallPattern.hpp"
#include "Rules/Patterns/Instruction.hpp"
#include "Rules/Patterns/PhiPattern.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
6 changes: 3 additions & 3 deletions src/Passes/Source/Rules/Notation/Phi.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include "Llvm/Llvm.hpp"
#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/Any.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/Operands/Phi.hpp"
#include "Rules/Patterns/AnyPattern.hpp"
#include "Rules/Patterns/Instruction.hpp"
#include "Rules/Patterns/PhiPattern.hpp"
#include "Rules/ReplacementRule.hpp"

#include <unordered_map>
Expand Down
6 changes: 3 additions & 3 deletions src/Passes/Source/Rules/Notation/Select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.

#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/Any.hpp"
#include "Rules/Operands/Call.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/Patterns/AnyPattern.hpp"
#include "Rules/Patterns/CallPattern.hpp"
#include "Rules/Patterns/Instruction.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
2 changes: 1 addition & 1 deletion src/Passes/Source/Rules/Notation/Store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/Patterns/Instruction.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
6 changes: 3 additions & 3 deletions src/Passes/Source/Rules/Notation/Switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the MIT License.

#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/Any.hpp"
#include "Rules/Operands/Call.hpp"
#include "Rules/Operands/Instruction.hpp"
#include "Rules/Patterns/AnyPattern.hpp"
#include "Rules/Patterns/CallPattern.hpp"
#include "Rules/Patterns/Instruction.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
2 changes: 1 addition & 1 deletion src/Passes/Source/Rules/Notation/UnnamedInvoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

#include "Rules/Notation/Notation.hpp"
#include "Rules/Operands/UnnamedInvoke.hpp"
#include "Rules/Patterns/UnnamedInvokePattern.hpp"

#include "Llvm/Llvm.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

#include "Rules/IOperandPrototype.hpp"
#include "Rules/Operands/Any.hpp"
#include "Rules/Patterns/AnyPattern.hpp"

namespace microsoft
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

#include "Rules/IOperandPrototype.hpp"
#include "Rules/Operands/Call.hpp"
#include "Rules/Patterns/CallPattern.hpp"

namespace microsoft
{
Expand Down
Loading