We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0543d71 commit b3dbf65Copy full SHA for b3dbf65
phase4/splc.py
@@ -61,9 +61,12 @@ def collect_params(ir_path) -> None:
61
# the register allocation algorithm
62
# 分配+查询reg
63
def reg(var: str) -> str:
64
- if var == '0':
65
- return '$0'
66
- else:
+ try:
+ if var == '0':
+ return '$0'
67
+ int(var)
68
+ return var
69
+ except:
70
reg = find_reg(var)
71
if reg:
72
return reg
@@ -79,6 +82,7 @@ def reg(var: str) -> str:
79
82
return f'{stack.index(var) + max_var_num << 2}($sp)'
80
83
81
84
85
+
86
def find_reg(var: str):
87
if var in register_table:
88
return f'${register_table.index(var) + save_reg}'
0 commit comments