MOVLIT of oper * word |
MOVSYM of oper * Symbol.symbol |
MOVLBL of oper * Label.label |
+ MOVSTR of oper * Stringref.stringref |
LDR of oper * oper |
STO of oper * oper |
MOV of oper * oper |
MOVLIT of oper * word |
MOVSYM of oper * Symbol.symbol |
MOVLBL of oper * Label.label |
+ MOVSTR of oper * Stringref.stringref |
LDR of oper * oper |
STO of oper * oper |
MOV of oper * oper |
fun pp_insn pr (MOVLIT (d, w)) = "\tmov"^pr^" "^(pp_oper d)^", #0x"^(Word.toString w)^"\n"
| pp_insn pr (MOVSYM (d, s)) = "\tmov"^pr^" "^(pp_oper d)^", #"^(Symbol.name s)^"\n"
| pp_insn pr (MOVLBL (d, l)) = "\tmov"^pr^" "^(pp_oper d)^", #"^(Label.name l)^"\n"
+ | pp_insn pr (MOVSTR (d, s)) = "\tmov"^pr^" "^(pp_oper d)^", #"^(Stringref.name s)^"\n"
| pp_insn pr (LDR (d, s)) = "\tldr"^pr^" "^(pp_oper d)^", ["^(pp_oper s)^"]\n"
| pp_insn pr (STO (d, s)) = "\tsto"^pr^" ["^(pp_oper d)^"], "^(pp_oper s)^"\n"
| pp_insn pr (MOV (d, s)) = "\tmov"^pr^" "^(pp_oper d)^", "^(pp_oper s)^"\n"
* d must be TEMP(t) or REG(r)
*)
and munch_exp d (T.CONST n) = [X.INSN (X.AL, X.MOVLIT(d, Word.fromLarge n))]
+ | munch_exp d (T.STRING s) = [X.INSN (X.AL, X.MOVSTR(d, s))]
| munch_exp d (T.NULLPTR) = [X.INSN (X.AL, X.MOVLIT(d, 0w0))]
| munch_exp d (T.TEMP(t)) = [X.INSN (X.AL, X.MOV(d, X.TEMP t))]
| munch_exp d (T.ARG(0)) = [X.INSN (X.AL, X.MOV(d, X.REG X.R0))]
| gendef (n, X.INSN(X.NV, _)) = ([SUCC (n+1)])
| gendef (n, X.INSN(_, X.MOVLIT(dest, _))) = (defhit dest @ [SUCC(n+1), ISMOVE])
| gendef (n, X.INSN(_, X.MOVSYM(dest, sym))) = (defhit dest @ [SUCC(n+1), ISMOVE])
+ | gendef (n, X.INSN(_, X.MOVSTR(dest, str))) = (defhit dest @ [SUCC(n+1), ISMOVE])
| gendef (n, X.INSN(X.AL, X.MOVLBL(X.REG X.PC, l))) = ([SUCC (findlabel l)])
| gendef (n, X.INSN(_, X.MOVLBL(X.REG X.PC, l))) = ([SUCC (n+1), SUCC (findlabel l)])
| gendef (n, X.INSN(_, X.MOVLBL(_, _))) = raise ErrorMsg.InternalError "MOVLBL with target neq PC"
(if isspilled op1
then spill (op1, spillreg1)
else [])
+ | transform (X.INSN (pred, X.MOVSTR (op1, w))) =
+ [ X.INSN (pred, X.MOVSTR (real_op1 op1, w)) ] @
+ (if isspilled op1
+ then spill (op1, spillreg1)
+ else [])
| transform (X.INSN (pred, X.MOVLBL (op1, w))) =
[ X.INSN (pred, X.MOVLBL (real_op1 op1, w)) ] @
(if isspilled op1