X-Git-Url: http://git.joshuawise.com/snipe.git/blobdiff_plain/075222c771a121b12d6f07f39af868ae14cd06a1..a83f1d602c6f50eb9ab0448a20f0ecb80fefcead:/codegen/codegen.sml?ds=sidebyside diff --git a/codegen/codegen.sml b/codegen/codegen.sml index aad1770..de8fa1e 100644 --- a/codegen/codegen.sml +++ b/codegen/codegen.sml @@ -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 @@ -125,9 +125,9 @@ struct (*| munch_exp d (T.BINOP(T.SUB, e1, T.CONST n)) = binophit_c d X.SUB e1 n | munch_exp d (T.BINOP(T.SUB, e1, T.TEMP t)) = binophit_t d X.SUB e1 t*) | munch_exp d (T.BINOP(T.SUB, e1, e2)) = binophit d X.SUB e1 e2 - | munch_exp d (T.BINOP(T.MUL, _, _)) = raise ErrorMsg.InternalError "MUL does not exist on blargcpu" - | munch_exp d (T.BINOP(T.DIV, _, _)) = raise ErrorMsg.InternalError "DIV does not exist on blargcpu" - | munch_exp d (T.BINOP(T.MOD, _, _)) = raise ErrorMsg.InternalError "MOD does not exist on blargcpu" + | munch_exp d (T.BINOP(T.MUL, e1, e2)) = munch_exp d (T.CALL (Symbol.symbol "__blarg_mul", [e1, e2])) + | munch_exp d (T.BINOP(T.DIV, e1, e2)) = munch_exp d (T.CALL (Symbol.symbol "__blarg_div", [e1, e2])) + | munch_exp d (T.BINOP(T.MOD, e1, e2)) = munch_exp d (T.CALL (Symbol.symbol "__blarg_mod", [e1, e2])) | munch_exp d (T.BINOP(T.LSH, e1, e2)) = binophit d X.SHL e1 e2 | munch_exp d (T.BINOP(T.RSH, e1, e2)) = binophit d X.SHR e1 e2 | munch_exp d (T.BINOP(T.BITAND, e1, e2)) = binophit d X.AND e1 e2 @@ -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")