aboutsummaryrefslogtreecommitdiff
path: root/crowbar_reference_compiler
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2020-12-28 14:26:42 -0700
committerMelody Horn <melody@boringcactus.com>2020-12-28 14:26:42 -0700
commit65afa06491818dc3187399c3f16dbf284bec761d (patch)
tree9ff79b83f841c474b8bee65ae05fdfaba5a4eefa /crowbar_reference_compiler
parent2a17d1324bd7c93a06b0abe687bf6e4d3953c003 (diff)
downloadreference-compiler-65afa06491818dc3187399c3f16dbf284bec761d.tar.gz
reference-compiler-65afa06491818dc3187399c3f16dbf284bec761d.zip
retain function call return value
Diffstat (limited to 'crowbar_reference_compiler')
-rw-r--r--crowbar_reference_compiler/ssagen.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/crowbar_reference_compiler/ssagen.py b/crowbar_reference_compiler/ssagen.py
index abf5c56..5212440 100644
--- a/crowbar_reference_compiler/ssagen.py
+++ b/crowbar_reference_compiler/ssagen.py
@@ -89,7 +89,10 @@ def _(target: FunctionCallExpression, context: CompileContext) -> SsaResult:
result += compile_to_ssa(expr, context)
arg_dest = context.next_temp - 1
args += [f"l %t{arg_dest}"]
- result.code.append(f"call ${target.function.name}({','.join(args)}, ...)")
+ result_dest = context.next_temp
+ context.next_temp += 1
+ # TODO size
+ result.code.append(f"%t{result_dest} =l call ${target.function.name}({','.join(args)})")
return result
@@ -291,7 +294,7 @@ def _(target: ArrayIndexExpression, context: CompileContext) -> SsaResult:
# TODO types
result.code.append(f"%t{offset} =l mul %t{index}, {scale}")
result.code.append(f"%t{address} =l add %t{base}, %t{offset}")
- result.code.append(f"%t{dest} =l loadsw %t{address}")
+ result.code.append(f"%t{dest} =l loadl %t{address}")
return result
@@ -326,7 +329,7 @@ def _(target: StructPointerElementExpression, context: CompileContext) -> SsaRes
context.next_temp += 1
# TODO types
result.code.append(f"%t{temp} =l add %t{base_dest}, {offset}")
- result.code.append(f"%t{result_dest} =l loadsw %t{temp}")
+ result.code.append(f"%t{result_dest} =l loadl %t{temp}")
return result
@@ -352,7 +355,7 @@ def _(target: DirectAssignment, context: CompileContext) -> SsaResult:
last_instr = sub_result.code.pop()
_, _, _, location = last_instr.split(' ')
# TODO type
- sub_result.code.append(f"storew %t{result_dest}, {location}")
+ sub_result.code.append(f"storel %t{result_dest}, {location}")
result += sub_result
else:
raise NotImplementedError('assign to ' + str(type(target.destination)))