Skip to content

Commit 3eaf4c8

Browse files
committed
Merge branch 'main' into roger/scf
2 parents 98152e2 + 99397cc commit 3eaf4c8

File tree

220 files changed

+3922
-3599
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+3922
-3599
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
steps:
2626
- uses: actions/checkout@v4
2727
- name: Install uv
28-
uses: astral-sh/setup-uv@v3
28+
uses: astral-sh/setup-uv@v4
2929
with:
3030
# Install a specific version of uv.
3131
version: "0.5.1"
@@ -39,7 +39,7 @@ jobs:
3939
# For example, using `pytest`
4040
run: uv run just coverage
4141
- name: Upload Coverage to Codecov
42-
uses: codecov/codecov-action@v4
42+
uses: codecov/codecov-action@v5
4343
with:
4444
files: coverage.xml # optional
4545
fail_ci_if_error: true # optional (default = false)

.github/workflows/devdoc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
fetch-depth: 0
1919
- name: Install uv
20-
uses: astral-sh/setup-uv@v3
20+
uses: astral-sh/setup-uv@v4
2121
with:
2222
# Install a specific version of uv.
2323
version: "0.5.1"

.github/workflows/doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919
- name: Install uv
20-
uses: astral-sh/setup-uv@v3
20+
uses: astral-sh/setup-uv@v4
2121
with:
2222
# Install a specific version of uv.
2323
version: "0.5.1"

.github/workflows/pub_doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
fetch-depth: 0
1919
- name: Install uv
20-
uses: astral-sh/setup-uv@v3
20+
uses: astral-sh/setup-uv@v4
2121
with:
2222
# Install a specific version of uv.
2323
version: "0.5.1"

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Release on JFrog
2+
on:
3+
push:
4+
tags:
5+
- "v*"
6+
7+
jobs:
8+
documentation:
9+
name: Publish package to JFrog
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v4
17+
with:
18+
# Install a specific version of uv.
19+
version: "0.5.1"
20+
enable-cache: true
21+
cache-dependency-glob: "uv.lock"
22+
- name: Install dependencies
23+
run: uv sync
24+
- name: Build
25+
run: uv build
26+
- name: Publish
27+
run: uv publish --publish-url ${{secrets.JFROG_KIRIN_URL}} --username ${{secrets.JFROG_KIRIN_USERNAME}} --password ${{secrets.JFROG_KIRIN_PASSWORD}}

docs/def.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ In this section, we will learn about the terminology used in Kirin IR. This will
1818

1919
::: kirin.ir.Attribute
2020

21-
::: kirin.ir.TypeAttribute
21+
::: kirin.ir.types.TypeAttribute
2222

2323
## Traits
2424

example/beer/interp.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
from random import randint
22

33
from attrs import Beer
4+
from stmts import Pour, Puke, Drink, NewBeer, RandomBranch
45
from dialect import dialect
5-
from stmts import Drink, NewBeer, Pour, Puke, RandomBranch
66

7-
from kirin.interp import DialectInterpreter, Interpreter, ResultValue, Successor, impl
7+
from kirin.interp import Frame, Successor, Interpreter, MethodTable, impl
88

99

1010
@dialect.register
11-
class BeerInterpreter(DialectInterpreter):
11+
class BeerInterpreter(MethodTable):
1212

1313
@impl(NewBeer)
14-
def new_beer(self, interp: Interpreter, stmt: NewBeer, values: tuple):
15-
return ResultValue(Beer(values[0]))
14+
def new_beer(self, interp: Interpreter, frame: Frame, stmt: NewBeer):
15+
return (Beer(frame.get(stmt.brand)),)
1616

1717
@impl(Drink)
18-
def drink(self, interp: Interpreter, stmt: Drink, values: tuple):
19-
print(f"Drinking {values[0].brand}")
20-
return ResultValue()
18+
def drink(self, interp: Interpreter, frame: Frame, stmt: Drink):
19+
print(f"Drinking {frame.get(stmt.beverage).brand}")
20+
return ()
2121

2222
@impl(Pour)
23-
def pour(self, interp: Interpreter, stmt: Pour, values: tuple):
24-
print(f"Pouring {values[0].brand} {values[1]}")
25-
return ResultValue()
23+
def pour(self, interp: Interpreter, frame: Frame, stmt: Pour):
24+
print(f"Pouring {frame.get(stmt.beverage).brand} {frame.get(stmt.amount)}")
25+
return ()
2626

2727
@impl(Puke)
28-
def puke(self, interp: Interpreter, stmt: Puke, values: tuple):
28+
def puke(self, interp: Interpreter, frame: Frame, stmt: Puke):
2929
print("Puking!!!")
30-
return ResultValue()
30+
return ()
3131

3232
@impl(RandomBranch)
33-
def random_branch(self, interp: Interpreter, stmt: RandomBranch, values: tuple):
33+
def random_branch(self, interp: Interpreter, frame: Frame, stmt: RandomBranch):
3434
frame = interp.state.current_frame()
3535
if randint(0, 1):
3636
return Successor(

example/beer/script.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
from stmts import Pour, Puke, Drink, NewBeer
12
from dialect import dialect
2-
from stmts import Drink, NewBeer, Pour, Puke
33

44
from interp import BeerInterpreter as BeerInterpreter
5+
from rewrite import RandomWalkBranch
56
from kirin.ir import dialect_group
67
from kirin.prelude import basic_no_opt
7-
from kirin.rewrite import Fixpoint, Walk
8-
from rewrite import RandomWalkBranch
8+
from kirin.rewrite import Walk, Fixpoint
99

1010

1111
# create our own beer dialect, it runs a random walk on the branches
@@ -24,14 +24,14 @@ def run_pass(mt):
2424
# type: ignore
2525
@beer
2626
def main(x):
27-
beer = NewBeer("budlight") # type: ignore
28-
Drink(beer) # type: ignore
29-
Pour(beer, 12) # type: ignore
27+
beer = NewBeer("budlight")
28+
Drink(beer)
29+
Pour(beer, 12)
3030
Puke()
3131
if x > 1:
32-
Drink(NewBeer("heineken")) # type: ignore
32+
Drink(NewBeer("heineken"))
3333
else:
34-
Drink(NewBeer("tsingdao")) # type: ignore
34+
Drink(NewBeer("tsingdao"))
3535
return x + 1
3636

3737

example/beer/stmts.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
from attrs import Beer
22
from dialect import dialect
33

4+
from kirin import ir, types
45
from kirin.decl import info, statement
5-
from kirin.dialects.py import types
6-
from kirin.ir import Block, IsTerminator, Pure, ResultValue, SSAValue, Statement
76

87

98
@statement(dialect=dialect)
10-
class NewBeer(Statement):
9+
class NewBeer(ir.Statement):
1110
name = "new_beer"
12-
traits = frozenset({Pure()})
13-
brand: SSAValue = info.argument(types.String)
14-
result: ResultValue = info.result(types.PyClass(Beer))
11+
traits = frozenset({ir.Pure()})
12+
brand: ir.SSAValue = info.argument(types.String)
13+
result: ir.ResultValue = info.result(types.PyClass(Beer))
1514

1615

1716
@statement(dialect=dialect)
18-
class Drink(Statement):
17+
class Drink(ir.Statement):
1918
name = "drink"
20-
beverage: SSAValue = info.argument(types.PyClass(Beer))
19+
beverage: ir.SSAValue = info.argument(types.PyClass(Beer))
2120

2221

2322
@statement(dialect=dialect)
24-
class Pour(Statement):
23+
class Pour(ir.Statement):
2524
name = "pour"
26-
beverage: SSAValue = info.argument(types.PyClass(Beer))
27-
amount: SSAValue = info.argument(types.Int)
25+
beverage: ir.SSAValue = info.argument(types.PyClass(Beer))
26+
amount: ir.SSAValue = info.argument(types.Int)
2827

2928

3029
@statement(dialect=dialect)
31-
class RandomBranch(Statement):
30+
class RandomBranch(ir.Statement):
3231
name = "random_br"
33-
traits = frozenset({IsTerminator()})
34-
cond: SSAValue = info.argument(types.Bool)
35-
then_arguments: tuple[SSAValue, ...] = info.argument()
36-
else_arguments: tuple[SSAValue, ...] = info.argument()
37-
then_successor: Block = info.block()
38-
else_successor: Block = info.block()
32+
traits = frozenset({ir.IsTerminator()})
33+
cond: ir.SSAValue = info.argument(types.Bool)
34+
then_arguments: tuple[ir.SSAValue, ...] = info.argument()
35+
else_arguments: tuple[ir.SSAValue, ...] = info.argument()
36+
then_successor: ir.Block = info.block()
37+
else_successor: ir.Block = info.block()
3938

4039

4140
@statement(dialect=dialect)
42-
class Puke(Statement):
41+
class Puke(ir.Statement):
4342
name = "puke"

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ nav:
4242
- IR declaration: reference/kirin/decl/
4343
- Exceptions: reference/kirin/exceptions.md
4444
- Data Structures:
45-
- Lattice: reference/kirin/lattice.md
45+
- Lattice: reference/kirin/lattice/abc.md
4646
- Graph: reference/kirin/graph.md
4747
- IdTable: reference/kirin/idtable.md
4848
- Source: reference/kirin/source.md

0 commit comments

Comments
 (0)