Skip to content

Commit eee712d

Browse files
committed
update to new kirin
1 parent 8115bf4 commit eee712d

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

src/bloqade/analysis/record/analysis.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,19 @@ class RecordAnalysis(ForwardExtra[RecordFrame, Record]):
4242
keys = ["record"]
4343
lattice = Record
4444

45-
def initialize_frame(self, code, *, has_parent_access: bool = False) -> RecordFrame:
46-
return RecordFrame(code, has_parent_access=has_parent_access)
45+
def initialize_frame(
46+
self, node: ir.Statement, *, has_parent_access: bool = False
47+
) -> RecordFrame:
48+
return RecordFrame(node, has_parent_access=has_parent_access)
4749

48-
def eval_stmt_fallback(self, frame: RecordFrame, stmt) -> tuple[Record, ...]:
49-
return tuple(self.lattice.bottom() for _ in stmt.results)
50+
def eval_stmt_fallback(
51+
self, frame: RecordFrame, node: ir.Statement
52+
) -> tuple[Record, ...]:
53+
return tuple(self.lattice.bottom() for _ in node.results)
5054

5155
def run_method(self, method, args: tuple[Record, ...]):
5256
# NOTE: we do not support dynamic calls here, thus no need to propagate method object
53-
return self.run_callable(method.code, (self.lattice.bottom(),) + args)
57+
return self.run_method(method.code, (self.lattice.bottom(),) + args)
5458

5559
T = TypeVar("T")
5660

@@ -63,3 +67,6 @@ def get_const_value(
6367
return hint.data
6468

6569
return None
70+
71+
def method_self(self, method: ir.Method) -> Record:
72+
return self.lattice.bottom()

test/analysis/record/test_record_analysis.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
from bloqade import squin
2-
3-
# from bloqade.analysis.record import RecordAnalysis
4-
# from bloqade.stim.passes.soft_flatten import SoftFlatten
2+
from bloqade.analysis.record import RecordAnalysis
3+
from bloqade.stim.passes.soft_flatten import SoftFlatten
54

65
"""
7-
86
@squin.kernel
97
def test():
108
qs = squin.qalloc(5)
@@ -49,18 +47,18 @@ def analysis_demo():
4947
qs = squin.qalloc(3)
5048
ms0 = squin.broadcast.measure(qs)
5149
ms1 = squin.broadcast.measure(qs)
52-
squin.set_detector(ms0, coordinates=(0, 0))
53-
squin.set_detector(ms1, coordinates=(0, 1))
50+
squin.set_detector(ms0, coordinates=[0, 0])
51+
squin.set_detector(ms1, coordinates=[0, 1])
5452
squin.broadcast.measure(qs)
55-
squin.set_detector(ms1, coordinates=(0, 2))
53+
squin.set_detector(ms1, coordinates=[0, 2])
5654

5755
# get aliasing to work
5856
ms1 = ms0
59-
squin.set_detector(ms1, coordinates=(1, 0))
57+
squin.set_detector(ms1, coordinates=[1, 0])
6058
# return ms1
6159

6260

63-
# SoftFlatten(dialects=analysis_demo.dialects).fixpoint(analysis_demo)
64-
# analysis_demo.print()
65-
# frame, _ = RecordAnalysis(dialects=analysis_demo.dialects).run_analysis(analysis_demo)
66-
# analysis_demo.print(analysis=frame.entries)
61+
SoftFlatten(dialects=analysis_demo.dialects).fixpoint(analysis_demo)
62+
analysis_demo.print()
63+
frame, _ = RecordAnalysis(dialects=analysis_demo.dialects).run(analysis_demo)
64+
analysis_demo.print(analysis=frame.entries)

0 commit comments

Comments
 (0)