Maestro 0.3.1
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
qasm Namespace Reference

Classes

class  AbstractSyntaxTree
struct  AddBarrierExpr
struct  AddBitCondBranchExpr
struct  AddCommentExpr
struct  AddCondQopBracedExpr
struct  AddCondQopExpr
struct  AddCregExpr
struct  AddDeclarationExpr
struct  AddDelayExpr
struct  AddGateDeclExpr
struct  AddGateExpr
struct  AddInputDeclExpr
struct  AddMeasureExpr
struct  AddModifiedGateExpr
struct  AddOpaqueDeclExpr
struct  AddQregExpr
struct  AddResetExpr
class  BinaryOperator
class  CircToQasm
struct  CondBitTest
struct  CondHeadType
class  Constant
struct  DelayType
struct  error_handler_
class  Expression
class  Function
class  IndexedId
struct  MakeBinaryExpression
struct  MakeBitCondHeadExpression
struct  MakeCondBitTestExpression
struct  MakeConstantExpression
struct  MakeCtrlModifierExpression
struct  MakeDelayExpr
struct  MakeFunctionExpression
struct  MakeIndexedIdExpression
struct  MakePowModifierExpression
struct  MakeRegCondHeadExpression
struct  MakeUnaryExpression
struct  MakeVariableExpression
struct  ModifierType
struct  Program
class  QasmToCirc
struct  QoperationStatement
struct  RejectGateBodyModifierExpr
struct  RejectMeasureWithoutTargetExpr
struct  RejectQasm3OnlyGateExpr
struct  RejectUnsupportedConstructExpr
class  UnaryOperator
class  Variable

Typedefs

typedef std::shared_ptr< AbstractSyntaxTreeAbstractSyntaxTreePtr
using ArgumentType = std::variant<std::string, IndexedId>
using BarrierType = MixedListType
using CondOpType = boost::fusion::vector<std::string, int, QopType>
using CXGateCallType = boost::fusion::vector<ArgumentType, ArgumentType>
using DeclarationRegistry = std::unordered_map<std::string, DeclarationKind>
using ExpGatecallType
using GatecallType = std::variant<SimpleGatecallType, ExpGatecallType>
using GateDeclOpType = std::variant<UopType, SimpleBarrierType>
using GateDeclType
using InputDeclType
using MeasureType = boost::fusion::vector<ArgumentType, ArgumentType>
using MixedListType = std::vector<ArgumentType>
using ModifiedUopType = boost::fusion::vector<ModifierListType, UopType>
using ModifierListType = std::vector<ModifierType>
using OpaqueDeclType
using ProgramType
using QopType = StatementType
using RegisterMap = std::unordered_map<std::string, IndexedId>
using ResetType = ArgumentType
using SimpleBarrierType = std::vector<std::string>
using SimpleExpType = std::variant<double, int, std::string>
using SimpleGatecallType = boost::fusion::vector<std::string, MixedListType>
using StatementType = QoperationStatement
using UGateCallType
using UopType = std::variant<UGateCallType, CXGateCallType, GatecallType>

Enumerations

enum class  DeclarationKind {
  Qubit ,
  Bit ,
  Input ,
  Gate ,
  Opaque
}
enum class  ModifierKind {
  Ctrl ,
  NegCtrl ,
  Inv ,
  Pow
}

Functions

void ApplyCondition (StatementType &stmt, const std::vector< int > &conditionBits, const std::vector< bool > &expectedValues)
template<typename Expr>
static AbstractSyntaxTreePtr Clone (Expr const &t)
std::string_view DeclarationKindName (DeclarationKind kind)
std::vector< bool > DecodeRegisterCondition (const std::string &registerName, int value, size_t width)
double EvaluateGateParameter (const Expression &parameter, const std::unordered_map< std::string, double > &variables)
template<class Time>
std::shared_ptr< Circuits::IConditionMakeEqualCondition (const std::vector< int > &conditionBits, const std::vector< bool > &expectedValues)
void RegisterDeclaration (DeclarationRegistry &declarations, const std::string &name, DeclarationKind kind)
void RejectPredicateMutationBeforeReevaluation (const std::vector< QopType > &body, const std::vector< int > &conditionBits, bool followedByElse, std::string_view branchName)
void RequireMatchingRegisterWidths (const std::vector< int > &left, const std::vector< int > &right, std::string_view operation)
std::vector< int > ResolveRegisterOperand (const ArgumentType &argument, const RegisterMap &registers, std::string_view kind)
double ValidateInputBinding (const std::string &name, const std::string &type, const boost::optional< int > &width, double value)
void ValidateInputDeclaration (const std::string &name, const std::string &type, const boost::optional< int > &width)
int ValidateRegisterAllocation (const IndexedId &id, int currentSize, std::string_view kind)

Variables

phx::function< AddBarrierExprAddBarrier
phx::function< AddCommentExprAddComment
phx::function< AddCondQopExprAddCondQop
phx::function< AddCondQopBracedExprAddCondQopBraced
phx::function< AddCregExprAddCreg
phx::function< AddDeclarationExprAddDeclaration
phx::function< AddDelayExprAddDelay
phx::function< AddGateExprAddGate
phx::function< AddGateDeclExprAddGateDecl
phx::function< AddInputDeclExprAddInputDecl
phx::function< AddMeasureExprAddMeasure
phx::function< AddModifiedGateExprAddModifiedGate
phx::function< AddOpaqueDeclExprAddOpaqueDecl
phx::function< AddQregExprAddQreg
phx::function< AddResetExprAddReset
phx::function< error_handler_ > const error_handler = error_handler_()
phx::function< MakeBinaryExpressionMakeBinary
phx::function< MakeBitCondHeadExpressionMakeBitCondHead
phx::function< MakeCondBitTestExpressionMakeCondBitTest
phx::function< MakeConstantExpressionMakeConstant
phx::function< MakeCtrlModifierExpressionMakeCtrlModifier
phx::function< MakeDelayExprMakeDelay
phx::function< MakeFunctionExpressionMakeFunction
phx::function< MakeIndexedIdExpressionMakeIndexedId
phx::function< MakePowModifierExpressionMakePowModifier
phx::function< MakeRegCondHeadExpressionMakeRegCondHead
phx::function< MakeUnaryExpressionMakeUnary
phx::function< MakeVariableExpressionMakeVariable
phx::function< RejectGateBodyModifierExprRejectGateBodyModifier
phx::function< RejectMeasureWithoutTargetExprRejectMeasureWithoutTarget
phx::function< RejectQasm3OnlyGateExprRejectQasm3OnlyGate
phx::function< RejectUnsupportedConstructExprRejectUnsupportedConstruct

Class Documentation

◆ qasm::CondBitTest

struct qasm::CondBitTest

Definition at line 330 of file SimpleOps.h.

Collaboration diagram for qasm::CondBitTest:
Class Members
IndexedId bit
bool expected = true

◆ qasm::CondHeadType

struct qasm::CondHeadType

Definition at line 335 of file SimpleOps.h.

Collaboration diagram for qasm::CondHeadType:
Class Members
vector< CondBitTest > bits
bool isBitForm = false
string regId
int regValue = 0

◆ qasm::DelayType

struct qasm::DelayType

Definition at line 303 of file SimpleOps.h.

Collaboration diagram for qasm::DelayType:
Class Members
double duration = 0.0
MixedListType operands

Typedef Documentation

◆ AbstractSyntaxTreePtr

Definition at line 59 of file Expr.h.

◆ ArgumentType

using qasm::ArgumentType = std::variant<std::string, IndexedId>

Definition at line 111 of file SimpleOps.h.

◆ BarrierType

Definition at line 302 of file SimpleOps.h.

◆ CondOpType

using qasm::CondOpType = boost::fusion::vector<std::string, int, QopType>

Definition at line 309 of file SimpleOps.h.

◆ CXGateCallType

using qasm::CXGateCallType = boost::fusion::vector<ArgumentType, ArgumentType>

Definition at line 165 of file SimpleOps.h.

◆ DeclarationRegistry

using qasm::DeclarationRegistry = std::unordered_map<std::string, DeclarationKind>

Definition at line 48 of file SimpleOps.h.

◆ ExpGatecallType

Initial value:
boost::fusion::vector<std::string, std::vector<Expression>, MixedListType>
std::vector< ArgumentType > MixedListType
Definition SimpleOps.h:113

Definition at line 159 of file SimpleOps.h.

◆ GatecallType

Definition at line 161 of file SimpleOps.h.

◆ GateDeclOpType

Definition at line 394 of file SimpleOps.h.

◆ GateDeclType

Initial value:
boost::fusion::vector<std::string, std::vector<std::string>,
std::vector<std::string>>

Definition at line 390 of file SimpleOps.h.

◆ InputDeclType

Initial value:
boost::fusion::vector<std::string, boost::optional<int>, std::string>

Definition at line 114 of file SimpleOps.h.

◆ MeasureType

using qasm::MeasureType = boost::fusion::vector<ArgumentType, ArgumentType>

Definition at line 301 of file SimpleOps.h.

◆ MixedListType

using qasm::MixedListType = std::vector<ArgumentType>

Definition at line 113 of file SimpleOps.h.

◆ ModifiedUopType

using qasm::ModifiedUopType = boost::fusion::vector<ModifierListType, UopType>

Definition at line 193 of file SimpleOps.h.

◆ ModifierListType

using qasm::ModifierListType = std::vector<ModifierType>

Definition at line 192 of file SimpleOps.h.

◆ OpaqueDeclType

Initial value:
boost::fusion::vector<std::string, std::vector<std::string>,
std::vector<std::string>>

Definition at line 395 of file SimpleOps.h.

◆ ProgramType

Initial value:
boost::fusion::vector<std::vector<std::string>, double,
std::vector<std::string>, std::vector<StatementType>>

Definition at line 296 of file SimpleOps.h.

◆ QopType

Definition at line 308 of file SimpleOps.h.

◆ RegisterMap

using qasm::RegisterMap = std::unordered_map<std::string, IndexedId>

Definition at line 112 of file SimpleOps.h.

◆ ResetType

Definition at line 300 of file SimpleOps.h.

◆ SimpleBarrierType

using qasm::SimpleBarrierType = std::vector<std::string>

Definition at line 393 of file SimpleOps.h.

◆ SimpleExpType

using qasm::SimpleExpType = std::variant<double, int, std::string>

Definition at line 109 of file SimpleOps.h.

◆ SimpleGatecallType

using qasm::SimpleGatecallType = boost::fusion::vector<std::string, MixedListType>

Definition at line 158 of file SimpleOps.h.

◆ StatementType

Definition at line 294 of file SimpleOps.h.

◆ UGateCallType

Initial value:
boost::fusion::vector<std::vector<Expression>, ArgumentType>
std::variant< std::string, IndexedId > ArgumentType
Definition SimpleOps.h:111

Definition at line 163 of file SimpleOps.h.

◆ UopType

Definition at line 167 of file SimpleOps.h.

Enumeration Type Documentation

◆ DeclarationKind

enum class qasm::DeclarationKind
strong
Enumerator
Qubit 
Bit 
Input 
Gate 
Opaque 

Definition at line 46 of file SimpleOps.h.

◆ ModifierKind

enum class qasm::ModifierKind
strong
Enumerator
Ctrl 
NegCtrl 
Inv 
Pow 

Definition at line 171 of file SimpleOps.h.

Function Documentation

◆ ApplyCondition()

◆ Clone()

template<typename Expr>
AbstractSyntaxTreePtr qasm::Clone ( Expr const & t)
static

◆ DeclarationKindName()

std::string_view qasm::DeclarationKindName ( DeclarationKind kind)
inline

Definition at line 50 of file SimpleOps.h.

References Bit, Gate, Input, Opaque, and Qubit.

Referenced by RegisterDeclaration().

◆ DecodeRegisterCondition()

std::vector< bool > qasm::DecodeRegisterCondition ( const std::string & registerName,
int value,
size_t width )
inline

◆ EvaluateGateParameter()

double qasm::EvaluateGateParameter ( const Expression & parameter,
const std::unordered_map< std::string, double > & variables )
inline

Definition at line 24 of file SyntaxTree.h.

References qasm::Expression::Eval().

Referenced by qasm::AddModifiedGateExpr::Canonicalize().

◆ MakeEqualCondition()

template<class Time>
std::shared_ptr< Circuits::ICondition > qasm::MakeEqualCondition ( const std::vector< int > & conditionBits,
const std::vector< bool > & expectedValues )
inline

◆ RegisterDeclaration()

void qasm::RegisterDeclaration ( DeclarationRegistry & declarations,
const std::string & name,
DeclarationKind kind )
inline

◆ RejectPredicateMutationBeforeReevaluation()

void qasm::RejectPredicateMutationBeforeReevaluation ( const std::vector< QopType > & body,
const std::vector< int > & conditionBits,
bool followedByElse,
std::string_view branchName )
inline

◆ RequireMatchingRegisterWidths()

void qasm::RequireMatchingRegisterWidths ( const std::vector< int > & left,
const std::vector< int > & right,
std::string_view operation )
inline

Definition at line 150 of file SimpleOps.h.

Referenced by qasm::AddMeasureExpr::operator()().

◆ ResolveRegisterOperand()

◆ ValidateInputBinding()

double qasm::ValidateInputBinding ( const std::string & name,
const std::string & type,
const boost::optional< int > & width,
double value )
inline

Definition at line 518 of file SimpleOps.h.

References ValidateInputDeclaration().

Referenced by qasm::AddInputDeclExpr::operator()().

◆ ValidateInputDeclaration()

void qasm::ValidateInputDeclaration ( const std::string & name,
const std::string & type,
const boost::optional< int > & width )
inline

Definition at line 482 of file SimpleOps.h.

Referenced by qasm::AddInputDeclExpr::operator()(), and ValidateInputBinding().

◆ ValidateRegisterAllocation()

int qasm::ValidateRegisterAllocation ( const IndexedId & id,
int currentSize,
std::string_view kind )
inline

Definition at line 80 of file SimpleOps.h.

Referenced by qasm::AddCregExpr::operator()(), and qasm::AddQregExpr::operator()().

Variable Documentation

◆ AddBarrier

phx::function<AddBarrierExpr> qasm::AddBarrier
inline

Definition at line 705 of file SimpleOps.h.

◆ AddComment

phx::function<AddCommentExpr> qasm::AddComment
inline

Definition at line 464 of file SimpleOps.h.

◆ AddCondQop

phx::function<AddCondQopExpr> qasm::AddCondQop
inline

Definition at line 1111 of file SyntaxTree.h.

◆ AddCondQopBraced

phx::function<AddCondQopBracedExpr> qasm::AddCondQopBraced
inline

Definition at line 1249 of file SyntaxTree.h.

◆ AddCreg

phx::function<AddCregExpr> qasm::AddCreg
inline

Definition at line 422 of file SimpleOps.h.

◆ AddDeclaration

phx::function<AddDeclarationExpr> qasm::AddDeclaration
inline

Definition at line 480 of file SimpleOps.h.

◆ AddDelay

phx::function<AddDelayExpr> qasm::AddDelay
inline

Definition at line 750 of file SimpleOps.h.

◆ AddGate

phx::function<AddGateExpr> qasm::AddGate
inline

Definition at line 543 of file SyntaxTree.h.

◆ AddGateDecl

phx::function<AddGateDeclExpr> qasm::AddGateDecl
inline

Definition at line 844 of file SimpleOps.h.

◆ AddInputDecl

phx::function<AddInputDeclExpr> qasm::AddInputDecl
inline

Definition at line 607 of file SimpleOps.h.

◆ AddMeasure

phx::function<AddMeasureExpr> qasm::AddMeasure
inline

Definition at line 630 of file SimpleOps.h.

◆ AddModifiedGate

phx::function<AddModifiedGateExpr> qasm::AddModifiedGate
inline

Definition at line 940 of file SyntaxTree.h.

◆ AddOpaqueDecl

phx::function<AddOpaqueDeclExpr> qasm::AddOpaqueDecl
inline

Definition at line 784 of file SimpleOps.h.

◆ AddQreg

phx::function<AddQregExpr> qasm::AddQreg
inline

Definition at line 447 of file SimpleOps.h.

◆ AddReset

phx::function<AddResetExpr> qasm::AddReset
inline

Definition at line 673 of file SimpleOps.h.

◆ error_handler

phx::function<error_handler_> const qasm::error_handler = error_handler_()
inline

Definition at line 35 of file qasm.h.

◆ MakeBinary

phx::function<MakeBinaryExpression> qasm::MakeBinary
inline

Definition at line 248 of file Expr.h.

◆ MakeBitCondHead

phx::function<MakeBitCondHeadExpression> qasm::MakeBitCondHead
inline

Definition at line 388 of file SimpleOps.h.

◆ MakeCondBitTest

phx::function<MakeCondBitTestExpression> qasm::MakeCondBitTest
inline

Definition at line 373 of file SimpleOps.h.

◆ MakeConstant

phx::function<MakeConstantExpression> qasm::MakeConstant
inline

Definition at line 105 of file Expr.h.

◆ MakeCtrlModifier

phx::function<MakeCtrlModifierExpression> qasm::MakeCtrlModifier
inline

Definition at line 255 of file SimpleOps.h.

◆ MakeDelay

phx::function<MakeDelayExpr> qasm::MakeDelay
inline

Definition at line 729 of file SimpleOps.h.

◆ MakeFunction

phx::function<MakeFunctionExpression> qasm::MakeFunction
inline

Definition at line 364 of file Expr.h.

◆ MakeIndexedId

phx::function<MakeIndexedIdExpression> qasm::MakeIndexedId
inline

Definition at line 107 of file SimpleOps.h.

◆ MakePowModifier

phx::function<MakePowModifierExpression> qasm::MakePowModifier
inline

Definition at line 214 of file SimpleOps.h.

◆ MakeRegCondHead

phx::function<MakeRegCondHeadExpression> qasm::MakeRegCondHead
inline

Definition at line 358 of file SimpleOps.h.

◆ MakeUnary

phx::function<MakeUnaryExpression> qasm::MakeUnary
inline

Definition at line 300 of file Expr.h.

◆ MakeVariable

phx::function<MakeVariableExpression> qasm::MakeVariable
inline

Definition at line 144 of file Expr.h.

◆ RejectGateBodyModifier

phx::function<RejectGateBodyModifierExpr> qasm::RejectGateBodyModifier
inline

Definition at line 960 of file SyntaxTree.h.

◆ RejectMeasureWithoutTarget

phx::function<RejectMeasureWithoutTargetExpr> qasm::RejectMeasureWithoutTarget
inline

Definition at line 657 of file SimpleOps.h.

◆ RejectQasm3OnlyGate

phx::function<RejectQasm3OnlyGateExpr> qasm::RejectQasm3OnlyGate
inline

Definition at line 1024 of file SyntaxTree.h.

◆ RejectUnsupportedConstruct

phx::function<RejectUnsupportedConstructExpr> qasm::RejectUnsupportedConstruct
inline

Definition at line 980 of file SyntaxTree.h.