File tree Expand file tree Collapse file tree
src/main/kotlin/deep/decaf/low/amd64 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,11 +10,15 @@ fun irExprToLow(expr: IRExpr): List<Instruction> {
1010 return when (expr) {
1111 is IRIntLiteral -> {
1212 instructions.add(MoveInstruction (ImmediateVal (expr.lit), Register .r10()))
13- Register .r10()
13+ val tmp = Label (getUUID())
14+ instructions.add(MoveInstruction (Register .r10(), tmp))
15+ tmp
1416 }
1517 is IRBoolLiteral -> {
1618 instructions.add(MoveInstruction (ImmediateVal (if (expr.lit) 1 else 0 ), Register .r10()))
17- Register .r10()
19+ val tmp = Label (getUUID())
20+ instructions.add(MoveInstruction (Register .r10(), tmp))
21+ tmp
1822 }
1923 is IRMethodCallExpr -> {
2024 val argLocations = expr.argList.map { traverse(it) }
@@ -294,8 +298,12 @@ fun irMethodToLow(method: IRMethodDeclaration): List<Block> {
294298 blocks.add(loopEndBlock)
295299 loopEndBlock
296300 }
297- is IRReturnStatement -> TODO ()
298- is IRBlockStatement -> TODO ()
301+ is IRReturnStatement -> {
302+ block.instructions.add(LeaveInstruction )
303+ block.instructions.add(ReturnInstruction )
304+ block
305+ }
306+ is IRBlockStatement -> convert(ir.block, block)
299307 }
300308 }
301309 is IRBlock -> {
You can’t perform that action at this time.
0 commit comments