From: Joshua Wise <jwise@andrew.cmu.edu>
Date: Sat, 10 Jul 2010 04:38:00 +0000 (-0400)
Subject: Propagate strings through the blarg backend.
X-Git-Url: http://git.joshuawise.com/snipe.git/commitdiff_plain/5c90fbb8681e975ccd0a1bc407b31daa1daef38a?ds=sidebyside

Propagate strings through the blarg backend.
---

diff --git a/codegen/blarg.sml b/codegen/blarg.sml
index c350b9d..cdd4a1b 100644
--- a/codegen/blarg.sml
+++ b/codegen/blarg.sml
@@ -19,6 +19,7 @@ sig
     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 |
@@ -76,6 +77,7 @@ struct
     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 |
@@ -204,6 +206,7 @@ struct
   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"
diff --git a/codegen/codegen.sml b/codegen/codegen.sml
index de8fa1e..29707a8 100644
--- a/codegen/codegen.sml
+++ b/codegen/codegen.sml
@@ -60,6 +60,7 @@ struct
    * 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))]
diff --git a/codegen/liveness.sml b/codegen/liveness.sml
index 6a7d89b..df411bb 100644
--- a/codegen/liveness.sml
+++ b/codegen/liveness.sml
@@ -106,6 +106,7 @@ struct
         | 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"
diff --git a/codegen/solidify.sml b/codegen/solidify.sml
index a2622e1..db3ccea 100644
--- a/codegen/solidify.sml
+++ b/codegen/solidify.sml
@@ -183,6 +183,11 @@ struct
             (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