Skip to content

bloqade.squin.rewrite.qasm3.qasm3_expr_to_py.QASM3ExprToPy

← Module overview

classQASM3ExprToPysource

bloqade.squin.rewrite.qasm3.qasm3_expr_to_py.QASM3ExprToPy

Bases: RewriteRule

Rewrite QASM3 expression statements to their py/math dialect equivalents.

class QASM3ExprToPy

This mirrors the QASM2Py rewrite rule but for the QASM3 expression dialect.

Attributes

NameTypeDefaultDescription
UNARY_OPSdict[type[ir.Statement], type[ir.Statement]]{expr.Neg: py.USub, expr.BitNot: py.Invert, expr.Sin: math.stmts.sin, expr.Cos: math.stmts.cos, expr.Tan: math.stmts.ta…
BINARY_OPSdict[type[ir.Statement], type[ir.Statement]]{expr.Add: py.Add, expr.Sub: py.Sub, expr.Mul: py.Mult, expr.Div: py.Div, expr.Pow: py.Pow, expr.Mod: py.Mod}

methodrewrite_Statementsource

bloqade.squin.rewrite.qasm3.qasm3_expr_to_py.QASM3ExprToPy.rewrite_Statement

def rewrite_Statement(node: ir.Statement) -> RewriteResult

Parameters

NameTypeDescription
nodeir.Statement

Returns

RewriteResult

source