Skip to content

Commit

Permalink
Type stringify_instruction_list
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Aug 19, 2024
1 parent 65727fe commit 587f381
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions loopy/kernel/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import islpy as isl
from islpy import dim_type
from pytools import memoize_on_first_arg, natsorted
from pytools.tag import Tag

from loopy.diagnostic import LoopyError, warn_with_kernel
from loopy.kernel import LoopKernel
Expand Down Expand Up @@ -1483,15 +1484,15 @@ def conform_to_uniform_length(s):

# {{{ stringify_instruction_list

def stringify_instruction_tag(tag):
def stringify_instruction_tag(tag: Tag) -> str:
from loopy.kernel.instruction import LegacyStringInstructionTag
if isinstance(tag, LegacyStringInstructionTag):
return f"S({tag.value})"
else:
return str(tag)


def stringify_instruction_list(kernel):
def stringify_instruction_list(kernel: LoopKernel) -> list[str]:
# {{{ topological sort

printed_insn_ids = set()
Expand Down Expand Up @@ -1525,7 +1526,7 @@ def insert_insn_into_order(insn):

leader = " " * uniform_arrow_length
lines = []
current_inames = [set()]
current_inames: list[set[str]] = [set()]

if uniform_arrow_length:
indent_level = [1]
Expand All @@ -1536,13 +1537,13 @@ def insert_insn_into_order(insn):

iname_order = kernel._get_iname_order_for_printing()

def add_pre_line(s):
def add_pre_line(s: str) -> None:
lines.append(leader + " " * indent_level[0] + s)

def add_main_line(s):
def add_main_line(s: str) -> None:
lines.append(arrows + " " * indent_level[0] + s)

def add_post_line(s):
def add_post_line(s: str) -> None:
lines.append(extender + " " * indent_level[0] + s)

def adapt_to_new_inames_list(new_inames):
Expand Down

0 comments on commit 587f381

Please sign in to comment.