]> Joshua Wise's Git repositories - snipe.git/commitdiff
Fix some stupid bugs in code generation.
authorJoshua Wise <jwise@andrew.cmu.edu>
Fri, 9 Jul 2010 03:21:28 +0000 (23:21 -0400)
committerJoshua Wise <jwise@andrew.cmu.edu>
Fri, 9 Jul 2010 03:21:28 +0000 (23:21 -0400)
bin/snipe
codegen/blarg.sml
codegen/codegen.sml
codegen/liveness.sml
top/top.sml

index 7f7417c969820c696e83341794369ee11dd90ea9..cd6230496c68d5303c1d04f0464e00cfd1418320 100755 (executable)
--- a/bin/snipe
+++ b/bin/snipe
@@ -1 +1 @@
-sml @SMLcmdname=$0 @SMLload=bin/snipe.heap.x86-darwin $*
+sml @SMLcmdname=$0 @SMLload=$(dirname $0)/snipe.heap.x86-darwin $*
index cf3ea4c59044e77bf940ff1309336acffce1e573..c350b9d4886e5911d06b5498b28afb59dc73f78c 100644 (file)
@@ -197,11 +197,11 @@ struct
                                    val compare = Int.compare
                                  end)
   
-  fun pp_oper (REG r) = "%" ^ (regname r)
+  fun pp_oper (REG r) = (regname r)
     | pp_oper (TEMP t) = (Temp.name t)
     | pp_oper (STACKARG i) = "arg#"^Int.toString i
   
-  fun pp_insn pr (MOVLIT (d, w)) = "\tmov"^pr^" "^(pp_oper d)^", #"^(Word.toString w)^"\n"
+  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 (LDR (d, s)) = "\tldr"^pr^" "^(pp_oper d)^", ["^(pp_oper s)^"]\n"
@@ -218,13 +218,13 @@ struct
     | pp_insn pr (NOTS (d, s)) = "\tnots"^pr^" "^(pp_oper d)^", "^(pp_oper s)^"\n"
     | pp_insn pr (PUSH (d, s)) = "\tpush"^pr^" "^(pp_oper d)^", "^(pp_oper s)^"\n"
     | pp_insn pr (POP (d, s)) = "\tpop"^pr^" "^(pp_oper d)^", "^(pp_oper s)^"\n"
-    | pp_insn pr (CALL (d, s, n)) = "\tcall"^pr^" "^(pp_oper d)^", "^(pp_oper s)^" # ("^(Int.toString n)^" args)\n"
+    | pp_insn pr (CALL (d, s, n)) = "\tcall"^pr^" "^(pp_oper d)^", "^(pp_oper s)^" @ ("^(Int.toString n)^" args)\n"
     | pp_insn pr (SHR (d, s)) = "\tshr"^pr^" "^(pp_oper d)^", "^(pp_oper s)^"\n"
     | pp_insn pr (SHL (d, s)) = "\tshl"^pr^" "^(pp_oper d)^", "^(pp_oper s)^"\n"
     
   (* pretty prints the asm *)
   fun print (DIRECTIVE(str)) = str ^ "\n"
-    | print (COMMENT(str)) = "// " ^ str ^ "\n"
+    | print (COMMENT(str)) = "@ " ^ str ^ "\n"
     | print (LABEL(l)) = Label.name l ^ ":\n"
     | print (INSN (pred, insn)) = pp_insn (predname pred) insn
     | print (LIVEIGN i) = print i
index 81819054f033d5a1d2d66fde840e62c8e6942511..de8fa1e7867f5fcc851a1bfb924bb9975ef31c4e 100644 (file)
@@ -40,7 +40,7 @@ struct
 (*      val _ = print ("s1 = " ^ Tm.sfx s1 ^ ", s2 = " ^ Tm.sfx s2 ^ ", ") *)
 (*      val _ = print ("rs = " ^ Tm.sfx rs ^ " from " ^ TU.Print.pp_exp e1 ^ " and " ^ TU.Print.pp_exp e2 ^ "\n") *)
     in
-      i1 @ i2 @ [X.INSN (X.AL, oper (d, t))]
+      [X.COMMENT "binophit" ] @ i1 @ i2 @ [X.INSN (X.AL, oper (d, t)), X.COMMENT "binophit done"]
     end
   
   (* cmphit : X.oper -> X.exp -> X.insn list
@@ -231,8 +231,8 @@ struct
 
   and condhit e1 e2 (pos, neg) =
     let
-      val t1 = X.TEMP (Temp.new ("var neq 1"))
-      val t2 = X.TEMP (Temp.new ("var neq 2"))
+      val t1 = X.TEMP (Temp.new ("var cond 1"))
+      val t2 = X.TEMP (Temp.new ("var cond 2"))
       val i1 = munch_exp t1 e1
       val i2 = munch_exp t2 e2
     in
@@ -250,11 +250,11 @@ struct
           (insns, neg, pos)
         end
     | munch_cond (T.BINOP(T.NEQ, e1, e2)) = condhit e1 e2 (X.NE, X.EQ)
-    | munch_cond (T.BINOP(T.EQ, e1, e2)) = condhit e1 e2 (X.EQ, X.NE)
-    | munch_cond (T.BINOP(T.LE, e1, e2)) = condhit e1 e2 (X.LE, X.GT)
-    | munch_cond (T.BINOP(T.LT, e1, e2)) = condhit e1 e2 (X.LT, X.GE)
-    | munch_cond (T.BINOP(T.GT, e1, e2)) = condhit e1 e2 (X.GT, X.LE)
-    | munch_cond (T.BINOP(T.GE, e1, e2)) = condhit e1 e2 (X.GE, X.LT)
+    | munch_cond (T.BINOP(T.EQ, e1, e2)) =  condhit e1 e2 (X.EQ, X.NE)
+    | munch_cond (T.BINOP(T.LE, e1, e2)) =  condhit e1 e2 (X.LE, X.GT)
+    | munch_cond (T.BINOP(T.LT, e1, e2)) =  condhit e1 e2 (X.LT, X.GE)
+    | munch_cond (T.BINOP(T.GT, e1, e2)) =  condhit e1 e2 (X.GT, X.LE)
+    | munch_cond (T.BINOP(T.GE, e1, e2)) =  condhit e1 e2 (X.GE, X.LT)
 
     | munch_cond (T.BINOP(T.BE, e1, e2)) = raise ErrorMsg.InternalError "memory safety not supported"
 
@@ -269,7 +269,7 @@ struct
   (* munch_lval : T.exp -> X.operand
    * Takes an expression that has been typechecked as being a valid lvalue and a location of a datum, and then returns an instruction list to store.
    *)
-  and munch_lval (T.TEMP t) oper = [X.INSN (X.AL, X.MOV (oper, X.TEMP t))]
+  and munch_lval (T.TEMP t) oper = [X.INSN (X.AL, X.MOV (X.TEMP t, oper))]
     | munch_lval (T.MEMORY m) oper = 
       let
         val t = X.TEMP (Tm.new "lv addr")
index 97037cb28db16d3a39bfa4924f7bad2c40ed8fa5..6a7d89b5f65bfbf1c53e0b8054da92dabcddee4c 100644 (file)
@@ -99,8 +99,8 @@ struct
       (* val gendef : ident * X.insn -> ident * pred list
        * generates the def/use/succ predicates for a single insn
        *)
-      fun gendef (n, X.DIRECTIVE(_))           = (nil)
-        | gendef (n, X.COMMENT(_))             = (nil)
+      fun gendef (n, X.DIRECTIVE(_))           = ([SUCC (n+1)])
+        | gendef (n, X.COMMENT(_))             = ([SUCC (n+1)])
         | gendef (n, X.LIVEIGN (_))            = ([SUCC (n+1)])
         | gendef (n, X.LABEL l)                = ([SUCC (n+1)])
         | gendef (n, X.INSN(X.NV, _))          = ([SUCC (n+1)])
index 49e7dc6c3516072e7d7d87bf88b842f3880425a5..006fa4685af5d4f531d6fe377cabb60c9ebed5a0 100644 (file)
@@ -142,10 +142,10 @@ struct
                   (fn () => List.app (TextIO.print o
                     (fn (t, i) =>
                       (Temp.name t) ^ " => " ^ (
-                        if (i <= Blarg.regtonum Blarg.R3)
+                        if (i <= 15)
                           then (Blarg.pp_oper (Blarg.REG (Blarg.numtoreg i)))
                         else
-                          "spill[" ^ Int.toString (i - Blarg.regtonum Blarg.R3) ^ "]")
+                          "spill[" ^ Int.toString (i - Blarg.regtonum Blarg.PC) ^ "]")
                         ^ "--"^ Int.toString i ^ "\n"))
                     colors) ()
 
This page took 0.032917 seconds and 4 git commands to generate.