Skip to content

Commit

Permalink
Abstract interpretation based analysis rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
yamaguchi1024 committed Jun 25, 2024
1 parent e115107 commit aeba85f
Show file tree
Hide file tree
Showing 6 changed files with 2,261 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/exo/API.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from .pattern_match import match_pattern
from .prelude import *
from .new_eff import Check_Aliasing
from .dataflow import dataflow_analysis

# Moved to new file
from .proc_eqv import decl_new_proc, derive_proc, assert_eqv_proc, check_eqv_proc
Expand Down Expand Up @@ -391,3 +392,6 @@ def is_eq(self, proc: "Procedure"):

def _root(self):
return IC.Cursor.create(self._loopir_proc)

def dataflow(self):
return dataflow_analysis(self._loopir_proc)
14 changes: 7 additions & 7 deletions src/exo/LoopIR_pprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,33 +321,33 @@ def ptype(self, t):
# LoopIR Pretty Printing


def _format_code(code):
def format_code(code):
return FormatCode(code)[0].rstrip("\n")


@extclass(LoopIR.proc)
def __str__(self):
return _format_code("\n".join(_print_proc(self, PrintEnv(), "")))
return format_code("\n".join(_print_proc(self, PrintEnv(), "")))


@extclass(LoopIR.fnarg)
def __str__(self):
return _format_code(_print_fnarg(self, PrintEnv()))
return format_code(_print_fnarg(self, PrintEnv()))


@extclass(LoopIR.stmt)
def __str__(self):
return _format_code("\n".join(_print_stmt(self, PrintEnv(), "")))
return format_code("\n".join(_print_stmt(self, PrintEnv(), "")))


@extclass(LoopIR.expr)
def __str__(self):
return _format_code(_print_expr(self, PrintEnv()))
return format_code(_print_expr(self, PrintEnv()))


@extclass(LoopIR.type)
def __str__(self):
return _format_code(_print_type(self, PrintEnv()))
return format_code(_print_type(self, PrintEnv()))


del __str__
Expand Down Expand Up @@ -588,7 +588,7 @@ def _print_cursor(cur):

root_cur = cur.root()
lines = _print_cursor_proc(root_cur, cur, PrintEnv(), "")
code = _format_code("\n".join(lines))
code = format_code("\n".join(lines))
# need to use "..." for Python parsing, but unquoted ellipses are prettier
code = code.replace('"..."', "...")
return code
Expand Down
Loading

0 comments on commit aeba85f

Please sign in to comment.