22from warnings import warn
33from dataclasses import field , dataclass
44
5- from bloqade .rewrite .passes import AggressiveUnroll
65import cirq
7- from kirin import ir , types , interp , passes
6+ from kirin import ir , types , interp
87from kirin .emit import EmitABC , EmitError , EmitFrame
98from kirin .interp import MethodTable , impl
10- from kirin .passes import inline
11- from kirin .dialects import func , py
9+ from kirin .dialects import py , func
1210from typing_extensions import Self
1311
1412from bloqade .squin import kernel
13+ from bloqade .rewrite .passes import AggressiveUnroll
1514
1615
1716def emit_circuit (
@@ -115,21 +114,17 @@ def main():
115114
116115 emitter = EmitCirq (qubits = circuit_qubits )
117116
118-
119-
120117 symbol_op_trait = mt .code .get_trait (ir .SymbolOpInterface )
121118 if (symbol_op_trait := mt .code .get_trait (ir .SymbolOpInterface )) is None :
122- raise EmitError (
123- f"The method is not a symbol, cannot emit circuit!"
124- )
119+ raise EmitError ("The method is not a symbol, cannot emit circuit!" )
125120
126121 sym_name = symbol_op_trait .get_sym_name (mt .code ).unwrap ()
127122
128123 if (signature_trait := mt .code .get_trait (ir .HasSignature )) is None :
129124 raise EmitError (
130125 f"The method { sym_name } does not have a signature, cannot emit circuit!"
131126 )
132-
127+
133128 signature = signature_trait .get_signature (mt .code )
134129 new_signature = func .Signature (inputs = (), output = signature .output )
135130
@@ -149,14 +144,13 @@ def main():
149144 arg_ssa .replace_by (value .result )
150145 entry_block .args .delete (arg_ssa )
151146
152- new_func = func .Function (sym_name = sym_name , body = callable_region , signature = new_signature )
147+ new_func = func .Function (
148+ sym_name = sym_name , body = callable_region , signature = new_signature
149+ )
153150 mt_ = ir .Method (None , None , sym_name , [], mt .dialects , new_func )
154151
155- passes . Fold (mt_ .dialects , no_raise = False ) (mt_ )
152+ AggressiveUnroll (mt_ .dialects ). fixpoint (mt_ )
156153 mt_ .print (hint = "const" )
157-
158- # AggressiveUnroll(mt_.dialects)(mt_)
159- # mt_.print(hint="const")
160154 return emitter .run (mt_ , args = ())
161155
162156
0 commit comments