44
55from bloqade import qasm2 , squin
66from bloqade .analysis import address
7+ from bloqade .squin .analysis import shape
78
89
910def as_int (value : int ):
@@ -18,21 +19,24 @@ def as_int(value: int):
1819 (qreg := qasm2 .core .QRegNew (n_qubits = n_qubits .result )),
1920 # Get qubits out
2021 (idx0 := as_int (0 )),
21- (q1 := qasm2 .core .QRegGet (reg = qreg .result , idx = idx0 .result )),
22+ (q0 := qasm2 .core .QRegGet (reg = qreg .result , idx = idx0 .result )),
2223 # Unwrap to get wires
23- (w1 := squin .wire .Unwrap (qubit = q1 .result )),
24- # Put them in an ilist and return to prevent elimination
25- # Put the wire into one operator
24+ (w1 := squin .wire .Unwrap (qubit = q0 .result )),
25+ # Pass wire into operator
2626 (op := squin .op .stmts .H ()),
2727 (v1 := squin .wire .Apply (op .result , w1 .result )),
28- (func .Return (v1 .results [0 ])),
28+ # Test Identity
29+ (id := squin .op .stmts .Identity (size = 1 )),
30+ (v2 := squin .wire .Apply (id .result , v1 .results [0 ])),
31+ # Keep Passing Operators
32+ (func .Return (v2 .results [0 ])),
2933]
3034
3135block = ir .Block (stmts )
3236block .args .append_from (types .MethodType [[], types .NoneType ], "main_self" )
3337func_wrapper = func .Function (
3438 sym_name = "main" ,
35- signature = func .Signature (inputs = (), output = squin . wire . WireType ),
39+ signature = func .Signature (inputs = (), output = ilist . IListType ),
3640 body = ir .Region (blocks = block ),
3741)
3842
@@ -51,3 +55,14 @@ def as_int(value: int):
5155frame , _ = address .AddressAnalysis (constructed_method .dialects ).run_analysis (
5256 constructed_method , no_raise = False
5357)
58+
59+ frame , _ = shape .ShapeAnalysis (constructed_method .dialects ).run_analysis (
60+ constructed_method , no_raise = False
61+ )
62+
63+ """
64+ frame, _ = address.AddressAnalysis(constructed_method.dialects).run_analysis(
65+ constructed_method, no_raise=False
66+ """
67+
68+ constructed_method .print (analysis = frame .entries )
0 commit comments