From: Joshua Wise Date: Mon, 5 Jul 2010 09:48:36 +0000 (-0400) Subject: Un-size trans X-Git-Url: http://git.joshuawise.com/snipe.git/commitdiff_plain/141a7120aec6ddf3ab097f275498d8e3a1b90401?ds=sidebyside Un-size trans --- diff --git a/trans/trans.sml b/trans/trans.sml index 7c70af1..d8807f0 100644 --- a/trans/trans.sml +++ b/trans/trans.sml @@ -109,23 +109,22 @@ struct | trans_exp env vartypes (A.FuncCall(func, stms)) = T.CALL(func, List.map - (fn exp => (trans_exp env vartypes exp, Temp.sts (Type.size (typeof' vartypes exp)))) - stms, - Temp.sts (Type.size (AstUtils.Function.returntype (Symbol.look' funcs func)))) + (fn exp => (trans_exp env vartypes exp)) + stms) | trans_exp env vartypes (A.Member (exp, id)) = let val apk = T.BINOP (T.ADD, trans_exp env vartypes exp, T.CONST (Word32.fromInt (offset_s id (typeof' vartypes exp)))) val tipo = type_s id (typeof' vartypes exp) in if Type.issmall tipo - then T.MEMORY(apk, Temp.sts (Type.size tipo)) + then T.MEMORY(apk) else apk end | trans_exp env vartypes (A.DerefMember (exp, id)) = trans_exp env vartypes (A.Member (A.Dereference (exp), id)) | trans_exp env vartypes (A.Dereference(exp)) = if (Type.issmall (deref (typeof' vartypes exp))) - then T.MEMORY(trans_exp env vartypes exp, Temp.sts (Type.size (deref (typeof' vartypes exp)))) + then T.MEMORY(trans_exp env vartypes exp) else trans_exp env vartypes exp | trans_exp env vartypes (A.ArrIndex(exp1, exp2)) = let @@ -141,33 +140,33 @@ struct T.MEMORY (T.BINOP ( T.SUB, trans_exp env vartypes exp1, - T.CONST 0w8), Temp.Long), + T.CONST 0w8)), trans_exp env vartypes exp2), T.NULLPTR, asubk) in if Type.issmall tipo - then T.MEMORY(d, Temp.sts (Type.size tipo)) + then T.MEMORY(d) else d end | trans_exp env vartypes (A.New(tipo)) = let - val t1 = T.TEMP (Temp.new "result" Temp.Quad) + val t1 = T.TEMP (Temp.new "result") in T.STMVAR ( [T.MOVE (t1, T.ALLOC (T.CONST (Word32.fromInt(sizeof tipo)))), - T.EFFECT (T.MEMORY (t1, Temp.Long))], + T.EFFECT (T.MEMORY (t1))], t1) end | trans_exp env vartypes (A.NewArr(tipo, exp)) = let val size = T.BINOP(T.MUL, trans_exp env vartypes exp, T.CONST(Word32.fromInt(sizeof tipo))) - val t1 = T.TEMP (Temp.new "allocated address" Temp.Quad) - val ts = T.TEMP (Temp.new "size" Temp.Long) + val t1 = T.TEMP (Temp.new "allocated address") + val ts = T.TEMP (Temp.new "size") in if not (Flag.isset Flags.safe) then T.STMVAR ([T.MOVE (t1, T.ALLOC size), - T.EFFECT (T.COND (T.BINOP (T.EQ, trans_exp env vartypes exp, T.CONST 0w0), T.CONST 0w0, T.MEMORY (t1, Temp.Long)))], + T.EFFECT (T.COND (T.BINOP (T.EQ, trans_exp env vartypes exp, T.CONST 0w0), T.CONST 0w0, T.MEMORY (t1)))], t1) else T.COND (T.BINOP(T.EQ, size, T.CONST 0w0), T.NULLPTR, @@ -178,7 +177,7 @@ struct T.NULLPTR, T.ALLOC (T.BINOP (T.ADD, size, T.CONST 0w8))) ), - T.MOVE(T.MEMORY (t1, Temp.Long), trans_exp env vartypes exp)], + T.MOVE(T.MEMORY (t1), trans_exp env vartypes exp)], T.BINOP(T.ADD, t1, T.CONST 0w8))) end | trans_exp env vartypes (A.Null) = T.NULLPTR @@ -196,17 +195,17 @@ struct let val te1 = trans_exp vars vartypes e1 val te2 = trans_exp vars vartypes e2 - val t1 = T.TEMP (Temp.new "memory deref cache" Temp.Quad) + val t1 = T.TEMP (Temp.new "memory deref cache") in case te1 - of T.MEMORY(m,s) => T.MOVE(t1, m) :: T.MOVE (T.MEMORY(t1,s), T.BINOP(trans_oper oop, T.MEMORY(t1,s), te2)) :: (trans_stms vars vartypes ls stms) + of T.MEMORY(m) => T.MOVE(t1, m) :: T.MOVE (T.MEMORY(t1), T.BINOP(trans_oper oop, T.MEMORY(t1), te2)) :: (trans_stms vars vartypes ls stms) | _ => T.MOVE(te1, T.BINOP(trans_oper oop, te1, te2)) :: (trans_stms vars vartypes ls stms) end | trans_stms vars vartypes ls (A.Return e::stms) = let val remainder = trans_stms vars vartypes ls stms in - T.RETURN (trans_exp vars vartypes e, Temp.sts (Type.size (typeof' vartypes e))) + T.RETURN (trans_exp vars vartypes e) :: remainder end | trans_stms vars vartypes ls (A.If(e, s, NONE)::stms) = @@ -291,7 +290,7 @@ struct let val allvars = foldr (fn ((name, t),b) => - Symbol.bind b (name, Temp.new (Symbol.name(name)) (Temp.sts (Type.size t)))) + Symbol.bind b (name, Temp.new (Symbol.name(name)))) Symbol.empty (args @ vars) val vartypes = foldr (fn ((i, t), b) => Symbol.bind b (i, t)) Symbol.empty (args @ vars) @@ -299,7 +298,7 @@ struct val (argn,_) = ListPair.unzip args val numberedargs = ListPair.zip (List.tabulate (length argn, fn x => x), argn) val argmv = map - (fn (n, argname) => T.MOVE(T.TEMP (Symbol.look' allvars argname), T.ARG (n, Temp.size (Symbol.look' allvars argname)))) + (fn (n, argname) => T.MOVE(T.TEMP (Symbol.look' allvars argname), T.ARG (n))) numberedargs in (T.FUNCTION(id, argmv @ b)) :: (trans_funcs l)