Skip to content

Commit e51a875

Browse files
authored
adding structural dialect group to prelude (#223)
as we start working with more of this, adding it as a prelude to make it more convenient. We will add more passes to the `structural` group later as we develop.
1 parent 7106db4 commit e51a875

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

src/kirin/prelude.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from kirin.ir import Method, dialect_group
99
from kirin.passes import aggressive
10-
from kirin.dialects import cf, func, math, ilist, lowering
10+
from kirin.dialects import cf, scf, func, math, ilist, lowering
1111
from kirin.dialects.py import (
1212
cmp,
1313
len,
@@ -160,3 +160,38 @@ def run_pass(
160160
typeinfer_pass(mt)
161161

162162
return run_pass
163+
164+
165+
@dialect_group(
166+
python_basic.union(
167+
[ilist, range, slice, scf, cf, func, math, lowering.func, lowering.call]
168+
)
169+
)
170+
def structural_no_opt(self):
171+
"""Structural kernel without optimization passes."""
172+
173+
def run_pass(method: Method) -> None:
174+
pass
175+
176+
return run_pass
177+
178+
179+
@dialect_group(
180+
python_basic.union(
181+
[ilist, range, slice, scf, cf, func, math, lowering.func, lowering.call]
182+
)
183+
)
184+
def structural(self):
185+
"""Structural kernel without optimization passes."""
186+
typeinfer_pass = TypeInfer(self)
187+
188+
def run_pass(
189+
method: Method, *, verify: bool = True, typeinfer: bool = True
190+
) -> None:
191+
if verify:
192+
method.verify()
193+
194+
if typeinfer:
195+
typeinfer_pass(method)
196+
197+
return run_pass

0 commit comments

Comments
 (0)