Skip to content

Commit 13135a3

Browse files
committed
more analysis work
1 parent d9c7bba commit 13135a3

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from kirin import ir, interp
2+
from kirin.analysis import Forward
3+
from kirin.analysis.forward import ForwardFrame
4+
5+
from bloqade.squin.op.types import OpType
6+
7+
from .lattice import Shape
8+
9+
10+
class ShapeAnalysis(Forward[Shape]):
11+
12+
keys = ["op.shape"]
13+
lattice = Shape
14+
15+
def initialize(self):
16+
super().initialize
17+
return self
18+
19+
def eval_stmt_fallback(
20+
self, frame: ForwardFrame[Shape], stmt: ir.Statement
21+
) -> tuple[Shape, ...] | interp.SpecialValue[Shape]:
22+
return tuple(
23+
(
24+
self.lattice.top()
25+
if result.type.is_subseteq(OpType)
26+
else self.lattice.bottom()
27+
)
28+
for result in stmt.results
29+
)
30+
31+
def run_method(self, method: ir.Method, args: tuple[Shape, ...]):
32+
# NOTE: we do not support dynamic calls here, thus no need to propagate method object
33+
return self.run_callable(method.code, (self.lattice.bottom(),) + args)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from kirin import interp
2+
3+
from bloqade import squin
4+
5+
""" from .lattice import (
6+
Shape,
7+
NoShape,
8+
OpShape,
9+
)
10+
11+
from .analysis import ShapeAnalysis """
12+
13+
14+
@squin.op.dialect.register(key="op.shape")
15+
class SquinOp(interp.MethodTable):
16+
17+
# Should be using the Sized trait
18+
# that the statements have
19+
pass

0 commit comments

Comments
 (0)