AnyDSL / thorin

The Higher-Order Intermediate Representation
https://anydsl.github.io
GNU Lesser General Public License v3.0
151 stars 15 forks source link

Rewritten scoping analysis #148

Closed Hugobros3 closed 9 months ago

Hugobros3 commented 9 months ago

This PR introduces a rewritten scoping analysis that is now able to figure out nesting. This new analysis removes the the ad-hoc "top level' analysis in partial_evaluation.

Additionally, this PR introduces a new pretty-printer and a scoped graphviz dump.

This PR compiles Rodent unmodified and passes Stincilla tests with a couple of small patches:

diff --git a/sorting_networks/bitonic.impala b/sorting_networks/bitonic.impala
index 2201825..0072e6f 100644
--- a/sorting_networks/bitonic.impala
+++ b/sorting_networks/bitonic.impala
@@ -3,7 +3,7 @@ fn @bitonic_sort[T](length: i32, cmp: fn(T, T) -> bool, read: fn(i32) -> T, writ
     let ascending = true; // sorting direction

     fn @(?n) greatest_power_of_two_less_than(n: i32) -> i32 {
-        fn @(?k) loop(k: i32) -> i32 {
+        fn @(?n & ?k) loop(k: i32) -> i32 {
             if k < n {
                 loop(k << 1)
             } else {

(This patch is required on development already)

diff --git a/matmul.impala b/matmul.impala
index bc862c3..860d494 100644
--- a/matmul.impala
+++ b/matmul.impala
@@ -65,6 +65,7 @@ fn matmul_auto_tiled(C: Mat, A: Mat, B: Mat) -> () {

         fn @(?cur_lvl) tile(cur_lvl: i32, il: i32, iu: i32, kl: i32, ku: i32, jl: i32, ju: i32) -> () {
             let step = get_step(cur_lvl);
+            pe_info[i32]("cur_lvl", cur_lvl);
             pe_info[i32]("step size", step);

             if step == 1 {

This last patch seems to be caused by different continuation ordering.