Commit 90b2a5d
authored
refactor fcf unroll (#147)
this PR address a few issues in previous #130
1. this should be called unroll instead of inline because it does not
inline an existing stdlib function.
2. #130 only supports the case when collection is a constant, this
resolves the case when constant propagation fails (e.g `fn` is not pure)
but fails when collection has a constant length but unknown (which is
why this rewrite is called unroll)
so now this rewrite relys on type parameter of `IList` which indicates
the size of the immutable list, thus `Map` etc. can be unrolled without
knowning how this list was constructed. (thanks to type inference on
generics)
```python
%3 = ilist.Map(%fn, %coll)
# get unrolled to
%v_1 = indexing.GetItem(%coll, 0)
%3 = func.call(%fn, %v_0)
%v_2 = indexing.GetItem(%coll, 1)
%4 = func.call(%fn, %v_1)
%v_3 = indexing.GetItem(%coll, 2)
%5 = func.call(%fn, %v_2)
```
then in the case `%coll = ilist.New(...)` the `GetItem` inlining pass
will replace getitem with the `SSAValue` referring to the element
directly.
cc: @kaihsin1 parent 59b0695 commit 90b2a5d
File tree
45 files changed
+807
-703
lines changed- src/kirin
- dialects
- fcf
- rewrite
- func
- ilist
- rewrite
- py
- ilist
- list
- ir/attrs
- test
- analysis/dataflow
- dialects
- fcf
- pystmts
- lowering
- print
- program/py
- rules
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
45 files changed
+807
-703
lines changedThis file was deleted.
This file was deleted.
This file was deleted.
Whitespace-only changes.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
Lines changed: 11 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
9 | 14 | | |
10 | 15 | | |
11 | 16 | | |
| 17 | + | |
12 | 18 | | |
13 | | - | |
14 | | - | |
| 19 | + | |
| 20 | + | |
15 | 21 | | |
| 22 | + | |
16 | 23 | | |
| 24 | + | |
17 | 25 | | |
File renamed without changes.
0 commit comments