@@ -33,12 +33,14 @@ class MipsSubroutineEmitter private[mips](emitter: MipsAsmEmitter, info: Subrout
3333 extends SubroutineEmitter (emitter, info) {
3434
3535 override def emitStoreToStack (src : Reg , temp : Temp ): Unit = {
36- if (! offsets.contains(temp)) if (temp.index < info.numArgs) { // Always map arg `i` to `SP + 4 * i`.
37- offsets(temp) = 4 * temp.index
38- }
39- else {
40- offsets(temp) = nextLocalOffset
41- nextLocalOffset += 4
36+ if (! offsets.contains(temp)) {
37+ if (temp.index < info.numArgs) { // Always map arg `i` to `SP + 4 * i`.
38+ offsets(temp) = 4 * temp.index
39+ }
40+ else {
41+ offsets(temp) = nextLocalOffset
42+ nextLocalOffset += 4
43+ }
4244 }
4345 buf += new Mips .NativeStoreWord (src, Mips .SP , offsets(temp))
4446 }
@@ -77,7 +79,9 @@ class MipsSubroutineEmitter private[mips](emitter: MipsAsmEmitter, info: Subrout
7779 for {
7880 (reg, i) <- Mips .calleeSaved.zipWithIndex
7981 if used(reg)
80- } printer.printInstr(new Mips .NativeStoreWord (reg, Mips .SP , info.argsSize + 4 * i), " save value of " + reg)
82+ } {
83+ printer.printInstr(new Mips .NativeStoreWord (reg, Mips .SP , info.argsSize + 4 * i), " save value of " + reg)
84+ }
8185 printer.printComment(" end of prologue" )
8286 printer.println()
8387
@@ -94,8 +98,10 @@ class MipsSubroutineEmitter private[mips](emitter: MipsAsmEmitter, info: Subrout
9498 for {
9599 (reg, i) <- Mips .calleeSaved.zipWithIndex
96100 if used(reg)
97- } printer.printInstr(new Mips .NativeLoadWord (Mips .calleeSaved(i), Mips .SP , info.argsSize + 4 * i),
98- " restore value of $S" + i)
101+ } {
102+ printer.printInstr(new Mips .NativeLoadWord (Mips .calleeSaved(i), Mips .SP , info.argsSize + 4 * i),
103+ " restore value of $S" + i)
104+ }
99105 if (info.hasCalls) {
100106 printer.printInstr(new Mips .NativeLoadWord (Mips .RA , Mips .SP , info.argsSize + 32 ), " restore the return address" )
101107 }
0 commit comments