Skip to content

Commit

Permalink
Fix instruction dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkskeller committed May 4, 2023
1 parent f9ff6b2 commit d6342d8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Compiler/allocator.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ def dependency_graph(self, merge_classes):

reg_nodes = {}
last_def = defaultdict_by_id(lambda: -1)
last_read = defaultdict_by_id(lambda: -1)
last_mem_write = []
last_mem_read = []
last_mem_write_of = defaultdict(list)
Expand All @@ -337,12 +338,16 @@ def add_edge(i, j):
d[j] = d[i]

def read(reg, n):
last_read[reg] = n
for dup in reg.duplicates:
if last_def[dup] != -1:
add_edge(last_def[dup], n)

def write(reg, n):
last_def[reg] = n
for dup in reg.duplicates:
if last_read[dup] not in (-1, n):
add_edge(last_read[dup], n)

def handle_mem_access(addr, reg_type, last_access_this_kind,
last_access_other_kind):
Expand Down

0 comments on commit d6342d8

Please sign in to comment.