Skip to content

Commit 5e1c221

Browse files
committed
debugging empty registry problem
1 parent 0c20b95 commit 5e1c221

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

squin_op_playground.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ def as_int(value: int):
4040
fold_pass = Fold(squin_with_qasm_core)
4141
fold_pass(constructed_method)
4242

43-
frame, _ = address.AddressAnalysis(constructed_method.dialects).run_analysis(
43+
address_frame, _ = address.AddressAnalysis(constructed_method.dialects).run_analysis(
4444
constructed_method, no_raise=False
4545
)
4646

47-
frame, _ = shape.ShapeAnalysis(constructed_method.dialects).run_analysis(
47+
constructed_method.print(analysis=address_frame.entries)
48+
49+
shape_frame, _ = shape.ShapeAnalysis(constructed_method.dialects).run_analysis(
4850
constructed_method, no_raise=False
4951
)
5052

@@ -53,4 +55,4 @@ def as_int(value: int):
5355
constructed_method, no_raise=False
5456
"""
5557

56-
constructed_method.print(analysis=frame.entries)
58+
constructed_method.print(analysis=shape_frame.entries)

src/bloqade/analysis/address/analysis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class AddressAnalysis(Forward[Address]):
2222
def initialize(self):
2323
super().initialize()
2424
self.next_address: int = 0
25+
print(self.registry.statements)
2526
return self
2627

2728
@property

src/bloqade/squin/analysis/shape/analysis.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# from typing import cast
22

3-
from kirin import ir, interp
3+
from kirin import ir
44
from kirin.analysis import Forward
55
from kirin.analysis.forward import ForwardFrame
66

@@ -17,12 +17,17 @@ class ShapeAnalysis(Forward[Shape]):
1717

1818
def initialize(self):
1919
super().initialize()
20+
print(self.registry.statements)
2021
return self
2122

2223
# Take a page from const prop in Kirin,
2324
# I can get the data I want from the SizedTrait
2425
# and go from there
26+
27+
## This gets called before the registry look up
2528
def eval_stmt(self, frame: ForwardFrame, stmt: ir.Statement):
29+
# something fishy, registry pops up empty?
30+
# This doesn't happen with the
2631
method = self.lookup_registry(frame, stmt)
2732
if method is not None:
2833
return method(self, frame, stmt)
@@ -37,9 +42,10 @@ def eval_stmt(self, frame: ForwardFrame, stmt: ir.Statement):
3742
else:
3843
return (NoShape(),)
3944

45+
# For when no implementation is found for the statement
4046
def eval_stmt_fallback(
4147
self, frame: ForwardFrame[Shape], stmt: ir.Statement
42-
) -> tuple[Shape, ...] | interp.SpecialValue[Shape]:
48+
) -> tuple[Shape, ...]: # some form of Shape will go back into the frame
4349
return tuple(
4450
(
4551
self.lattice.top()

0 commit comments

Comments
 (0)