Documentation for microsoft::quantum::IOperandPrototype

microsoft::quantum::IOperandPrototype

More...

#include <Rules/IOperandPrototype.hpp>

Inherited by microsoft::quantum::AnyPattern, microsoft::quantum::BasicBlockPattern, microsoft::quantum::BitCastPattern, microsoft::quantum::BranchPattern, microsoft::quantum::CallPattern, microsoft::quantum::ConstIntPattern, microsoft::quantum::IntToPtrPattern, microsoft::quantum::LoadPattern, microsoft::quantum::PhiPattern, microsoft::quantum::SelectPattern, microsoft::quantum::StorePattern, microsoft::quantum::SwitchPattern, microsoft::quantum::UnnamedInvokePattern, microsoft::quantum::ZExtPattern

Public Types

Name
using llvm::Instruction Instruction
using std::string String
using llvm::Value Value
using std::shared_ptr< IOperandPrototype > Child
using std::vector< Child > Children
using std::unordered_map< std::string, Value * > Captures

Public Functions

Name
IOperandPrototype() =default
virtual ~IOperandPrototype()
virtual bool match(Value * value, Captures & captures) const =0
virtual Child copy() const =0
void addChild(Child const & child)
void captureAs(std::string capture_name)

Protected Functions

Name
bool fail(Value * value, Captures & captures) const
Function which should be called whenever a match fails.
bool success(Value * value, Captures & captures) const
Function which should be called whenever a match is successful.
bool matchChildren(Value * value, Captures & captures) const
Subroutine to match all children.
void copyPropertiesFrom(IOperandPrototype const & other)

Detailed Description

class microsoft::quantum::IOperandPrototype;

IOperandPrototype describes an IR pattern and allows matching against LLVMs llvm::Value type. Each value may or may not be captured during the matching process which means that they are stored in a map under a given name. Capturing is enabled using captureAs(name) which sets the name the value should be stored under.

Public Types Documentation

using Instruction

using microsoft::quantum::IOperandPrototype::Instruction =  llvm::Instruction;

using String

using microsoft::quantum::IOperandPrototype::String =  std::string;

using Value

using microsoft::quantum::IOperandPrototype::Value =  llvm::Value;

using Child

using microsoft::quantum::IOperandPrototype::Child =  std::shared_ptr<IOperandPrototype>;

using Children

using microsoft::quantum::IOperandPrototype::Children =  std::vector<Child>;

using Captures

using microsoft::quantum::IOperandPrototype::Captures =  std::unordered_map<std::string, Value*>;

Public Functions Documentation

function IOperandPrototype

IOperandPrototype() =default

function ~IOperandPrototype

virtual ~IOperandPrototype()

function match

virtual bool match(
    Value * value,
    Captures & captures
) const =0

Reimplemented by: microsoft::quantum::AnyPattern::match, microsoft::quantum::CallPattern::match, microsoft::quantum::StorePattern::match, microsoft::quantum::LoadPattern::match, microsoft::quantum::BitCastPattern::match, microsoft::quantum::IntToPtrPattern::match, microsoft::quantum::ConstIntPattern::match, microsoft::quantum::BranchPattern::match, microsoft::quantum::SelectPattern::match, microsoft::quantum::BasicBlockPattern::match, microsoft::quantum::SwitchPattern::match, microsoft::quantum::ZExtPattern::match, microsoft::quantum::PhiPattern::match, microsoft::quantum::UnnamedInvokePattern::match

Interface function which determines if a given Value matches the implemented pattern. It is expected that any implementation of match will return a call to either [success()](/qat/Api/Classes/classmicrosoft_1_1quantum_1_1_i_operand_prototype/#function-success) or [fail()](/qat/Api/Classes/classmicrosoft_1_1quantum_1_1_i_operand_prototype/#function-fail). These functions will, in turn, ensure that the node is captured in the capture table (and erased upon backtracking) as well as matching children.

function copy

virtual Child copy() const =0

Reimplemented by: microsoft::quantum::AnyPattern::copy, microsoft::quantum::CallPattern::copy, microsoft::quantum::StorePattern::copy, microsoft::quantum::LoadPattern::copy, microsoft::quantum::BitCastPattern::copy, microsoft::quantum::IntToPtrPattern::copy, microsoft::quantum::ConstIntPattern::copy, microsoft::quantum::BranchPattern::copy, microsoft::quantum::SelectPattern::copy, microsoft::quantum::BasicBlockPattern::copy, microsoft::quantum::SwitchPattern::copy, microsoft::quantum::ZExtPattern::copy, microsoft::quantum::PhiPattern::copy, microsoft::quantum::UnnamedInvokePattern::copy

Interface function which defines a copy operation of the underlying implementation. Note that unlike normal copy operators this operation returns a shared pointer to the new copy.

function addChild

void addChild(
    Child const & child
)

Adds a child to be matched against the matches children. Children are matched in order and by size.

function captureAs

void captureAs(
    std::string capture_name
)

Flags that this operand should be captured. This function ensures that the captured operand is given a name. The subsequent logic in this class is responsible for capturing (upon match) and uncapturing (upon backtrack) with specified name

Protected Functions Documentation

function fail

bool fail(
    Value * value,
    Captures & captures
) const

Function which should be called whenever a match fails.

function success

bool success(
    Value * value,
    Captures & captures
) const

Function which should be called whenever a match is successful.

function matchChildren

bool matchChildren(
    Value * value,
    Captures & captures
) const

Subroutine to match all children.

function copyPropertiesFrom

inline void copyPropertiesFrom(
    IOperandPrototype const & other
)

Shallow copy of the operand to allow name change of the capture


Updated on 1 August 2023 at 16:25:10 UTC