Skip to content

Commit

Permalink
修好了1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tao1122334 committed Jan 11, 2024
1 parent 0543d71 commit b3dbf65
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions phase4/splc.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ def collect_params(ir_path) -> None:
# the register allocation algorithm
# 分配+查询reg
def reg(var: str) -> str:
if var == '0':
return '$0'
else:
try:
if var == '0':
return '$0'
int(var)
return var
except:
reg = find_reg(var)
if reg:
return reg
Expand All @@ -79,6 +82,7 @@ def reg(var: str) -> str:
return f'{stack.index(var) + max_var_num << 2}($sp)'



def find_reg(var: str):
if var in register_table:
return f'${register_table.index(var) + save_reg}'
Expand Down

0 comments on commit b3dbf65

Please sign in to comment.