Documentation for microsoft::quantum::ReplacementRule
microsoft::quantum::ReplacementRule
#include <Rules/ReplacementRule.hpp>
Public Types
Name | |
---|---|
using IOperandPrototype::Captures | Captures Table to store LLVM values using a name. |
using llvm::Value | Value Value alias for shorthand usage. |
using std::shared_ptr< IOperandPrototype > | IOperandPrototypePtr Pointer to the pattern type. |
using llvm::IRBuilder<> | Builder Builder alias for shorthand notation. |
using std::vector< std::pair< Value *, Value * > > | Replacements List of replacements. |
using std::function< bool(Builder &, Value *, Captures &, Replacements &)> | ReplaceFunction Function to perform replacements. |
Public Functions
Name | |
---|---|
ReplacementRule() =default | |
ReplacementRule(String const & name, IOperandPrototypePtr && pattern, ReplaceFunction && replacer) | |
ReplacementRule(IOperandPrototypePtr && pattern, ReplaceFunction && replacer) | |
void | setPattern(IOperandPrototypePtr && pattern) Sets the pattern describing logic to be replaced. |
void | setReplacer(ReplaceFunction const & replacer) |
bool | match(Value * value, Captures & captures) const |
bool | replace(Builder & builder, Value * value, Captures & captures, Replacements & replacements) const Invokes the replacer given a matched value and its corresponding captures. |
String | name() const |
Detailed Description
class microsoft::quantum::ReplacementRule;
Rule that describes a pattern and how to make a replacement of the matched values. The class contains a OperandPrototype which is used to test whether an LLVM IR value follows a specific pattern. The class also holds a function pointer to logic that allows replacement of the specified value.
Public Types Documentation
using Captures
using microsoft::quantum::ReplacementRule::Captures = IOperandPrototype::Captures;
Table to store LLVM values using a name.
using Value
using microsoft::quantum::ReplacementRule::Value = llvm::Value;
Value alias for shorthand usage.
using IOperandPrototypePtr
using microsoft::quantum::ReplacementRule::IOperandPrototypePtr = std::shared_ptr<IOperandPrototype>;
Pointer to the pattern type.
using Builder
using microsoft::quantum::ReplacementRule::Builder = llvm::IRBuilder<>;
Builder alias for shorthand notation.
using Replacements
using microsoft::quantum::ReplacementRule::Replacements = std::vector<std::pair<Value*, Value*> >;
List of replacements.
using ReplaceFunction
using microsoft::quantum::ReplacementRule::ReplaceFunction = std::function<bool(Builder&, Value*, Captures&, Replacements&)>;
Function to perform replacements.
Public Functions Documentation
function ReplacementRule
ReplacementRule() =default
function ReplacementRule
ReplacementRule(
String const & name,
IOperandPrototypePtr && pattern,
ReplaceFunction && replacer
)
function ReplacementRule
ReplacementRule(
IOperandPrototypePtr && pattern,
ReplaceFunction && replacer
)
function setPattern
void setPattern(
IOperandPrototypePtr && pattern
)
Sets the pattern describing logic to be replaced.
function setReplacer
void setReplacer(
ReplaceFunction const & replacer
)
Sets the replacer logic which given a successful match will perform a replacement on the IR.
function match
bool match(
Value * value,
Captures & captures
) const
Tests whether a given value matches the rule pattern and store captures. The function returns true if the match was successful in which case captures are recorded.
function replace
bool replace(
Builder & builder,
Value * value,
Captures & captures,
Replacements & replacements
) const
Invokes the replacer given a matched value and its corresponding captures.
function name
String name() const
Updated on 1 August 2023 at 16:25:10 UTC