Skip to content

Commit

Permalink
Several corrections. Multiple new code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
perezzini committed Dec 2, 2017
1 parent da8e043 commit cbbb937
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions tigercodegen.sml
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,14 @@ struct
jump=NONE
})

| munchStm(MOVE(TEMP t1, TEMP t2)) =
emit(tigerassem.MOVE{
assem="movq `s0, `d0\n",
src=t2,
dst=t1
})

| munchStm(MOVE(TEMP t, CALL(NAME f, args))) =
let
val _ = munchStm(EXP(CALL(NAME f, args))) (* "Execute" call *)
in
emit(tigerassem.MOVE{
assem="movq `s0, `d0\n",
src=tigerframe.rv,
dst=t
})
end
(munchStm(EXP(CALL(NAME f, args))); (* Execute call *)
emit(tigerassem.MOVE{
assem="movq `s0, `d0\n",
src=tigerframe.rv,
dst=t
}))

| munchStm(MOVE(TEMP t, e)) =
emit(tigerassem.MOVE{
Expand All @@ -152,7 +143,7 @@ struct
dst=t
})

| munchStm(MOVE(_, _)) = raise Fail "Error - munchStm(): MOVE inválido a un no temporario/memoria"
| munchStm(MOVE _) = raise Fail "Error - munchStm(): MOVE inválido a un no temporario/memoria"

| munchStm(LABEL lab) =
emit(tigerassem.LABEL{
Expand Down Expand Up @@ -280,43 +271,43 @@ struct
let
val _ = case a of
CONST i => emit(OPER{
assem="pushq $"^utils.intToString i^"\n",
assem="pushq $"^utils.intToString i^" #\tFROM tigercodegen.munchArgs()\n",
src=[],
dst=[],
jump=NONE
})
| NAME l => emit(OPER{
assem="pushq $"^l^"\n",
assem="pushq $"^l^" #\tFROM tigercodegen.munchArgs()\n",
src=[],
dst=[],
jump=NONE
})
| TEMP t => emit(OPER{
assem="pushq `s0\n",
assem="pushq `s0 #\tFROM tigercodegen.munchArgs()\n",
src=[t],
dst=[],
jump=NONE
})
| MEM(TEMP t) => emit(OPER{
assem="pushq (`s0)\n",
assem="pushq (`s0) #\tFROM tigercodegen.munchArgs()\n",
src=[t],
dst=[],
jump=NONE
})
| MEM(BINOP(PLUS, e, CONST i)) => emit(OPER{
assem="pushq "^utils.intToString i^"(`s0)\n",
assem="pushq "^utils.intToString i^"(`s0) #\tFROM tigercodegen.munchArgs()\n",
src=[munchExp e],
dst=[],
jump=NONE
})
| MEM(e) => emit(OPER{
assem="pushq (`s0)\n",
assem="pushq (`s0) #\tFROM tigercodegen.munchArgs()\n",
src=[munchExp e],
dst=[],
jump=NONE
})
| _ => emit(OPER{
assem="pushq `s0\n",
assem="pushq `s0 #\tFROM tigercodegen.munchArgs()\n",
src=[munchExp a],
dst=[],
jump=NONE
Expand Down Expand Up @@ -372,7 +363,7 @@ struct
dst=[r],
jump=NONE
})))

(*
| munchExp(BINOP(PLUS, NAME l, e)) =
generateTmp(fn r =>
(munchStm(MOVE(TEMP r, e));
Expand All @@ -382,6 +373,7 @@ struct
dst=[r],
jump=NONE
})))
*)

| munchExp(BINOP(PLUS, TEMP t, e)) =
generateTmp(fn r =>
Expand Down Expand Up @@ -456,7 +448,7 @@ struct
dst=[r],
jump=NONE
})))

(*
| munchExp(BINOP(MINUS, e, NAME l)) =
generateTmp(fn r =>
(munchStm(MOVE(TEMP r, e));
Expand All @@ -466,6 +458,7 @@ struct
dst=[r],
jump=NONE
})))
*)

| munchExp(BINOP(MINUS, e, TEMP t)) =
generateTmp(fn r =>
Expand Down

0 comments on commit cbbb937

Please sign in to comment.