Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/c-util/tree-to-c-fn.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/c-util/tree-to-c-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1521, Mon Oct 10 14:19:33 2011 UTC revision 1522, Mon Oct 10 15:34:37 2011 UTC
# Line 61  Line 61 
61      fun trType ty = (case ty      fun trType ty = (case ty
62             of Ty.BoolTy => CLang.T_Named "bool"             of Ty.BoolTy => CLang.T_Named "bool"
63              | Ty.StringTy => CL.charPtr              | Ty.StringTy => CL.charPtr
64              | Ty.IVecTy 1 => !N.gIntTy              | Ty.IntTy => !N.gIntTy
             | Ty.IVecTy n => CL.T_Named(N.ivecTy n)  
65              | Ty.TensorTy[] => !N.gRealTy              | Ty.TensorTy[] => !N.gRealTy
66              | Ty.TensorTy[n] => CL.T_Named(N.vecTy n)              | Ty.TensorTy[n] => CL.T_Named(N.vecTy n)
67              | Ty.TensorTy[n, m] => CL.T_Named(N.matTy(n,m))              | Ty.TensorTy[n, m] => CL.T_Named(N.matTy(n,m))
68                | Ty.SeqTy(Ty.IntTy, n) => CL.T_Named(N.ivecTy n)
69                | Ty.SeqTy(Ty.TensorTy[] , n) => CL.T_Named(N.vecTy n)
70              | Ty.AddrTy(ImageInfo.ImgInfo{ty=(_, rTy), ...}) => CL.T_Ptr(CL.T_Num rTy)              | Ty.AddrTy(ImageInfo.ImgInfo{ty=(_, rTy), ...}) => CL.T_Ptr(CL.T_Num rTy)
71              | Ty.ImageTy(ImageInfo.ImgInfo{dim, ...}) => CL.T_Ptr(CL.T_Named(N.imageTy dim))              | Ty.ImageTy(ImageInfo.ImgInfo{dim, ...}) => CL.T_Ptr(CL.T_Named(N.imageTy dim))
72              | _ => raise Fail(concat["TreeToC.trType(", Ty.toString ty, ")"])              | _ => raise Fail(concat["TreeToC.trType(", Ty.toString ty, ")"])
# Line 128  Line 129 
129              | (Op.Mul ty, [a, b]) => CL.mkBinOp(a, CL.#*, b)              | (Op.Mul ty, [a, b]) => CL.mkBinOp(a, CL.#*, b)
130              | (Op.Div ty, [a, b]) => CL.mkBinOp(a, CL.#/, b)              | (Op.Div ty, [a, b]) => CL.mkBinOp(a, CL.#/, b)
131              | (Op.Neg ty, [a]) => CL.mkUnOp(CL.%-, a)              | (Op.Neg ty, [a]) => CL.mkUnOp(CL.%-, a)
132              | (Op.Abs(Ty.IVecTy 1), args) => CL.mkApply("abs", args)              | (Op.Abs(Ty.IntTy), args) => CL.mkApply("abs", args)
133              | (Op.Abs(Ty.TensorTy[]), args) => CL.mkApply(N.fabs(), args)              | (Op.Abs(Ty.TensorTy[]), args) => CL.mkApply(N.fabs(), args)
134              | (Op.Abs ty, [a]) => raise Fail(concat["Abs<", Ty.toString ty, ">"])              | (Op.Abs ty, [a]) => raise Fail(concat["Abs<", Ty.toString ty, ">"])
135              | (Op.LT ty, [a, b]) => CL.mkBinOp(a, CL.#<, b)              | (Op.LT ty, [a, b]) => CL.mkBinOp(a, CL.#<, b)
# Line 163  Line 164 
164                    then CL.E_Apply(N.mulMatMat(m,n,p), args)                    then CL.E_Apply(N.mulMatMat(m,n,p), args)
165                    else raise Fail "unsupported matrix-matrix multiply"                    else raise Fail "unsupported matrix-matrix multiply"
166              | (Op.Cross, args) => CL.E_Apply(N.cross(), args)              | (Op.Cross, args) => CL.E_Apply(N.cross(), args)
167              | (Op.Select(Ty.IVecTy n, i), [a]) => ivecIndex (a, n, i)              | (Op.Select(Ty.SeqTy(Ty.IntTy, n), i), [a]) => ivecIndex (a, n, i)
168              | (Op.Select(Ty.TensorTy[n], i), [a]) => vecIndex (a, n, i)              | (Op.Select(Ty.TensorTy[n], i), [a]) => vecIndex (a, n, i)
169              | (Op.Norm(Ty.TensorTy[n]), args) => CL.E_Apply(N.length n, args)              | (Op.Norm(Ty.TensorTy[n]), args) => CL.E_Apply(N.length n, args)
170              | (Op.Norm(Ty.TensorTy[m,n]), args) => CL.E_Apply(N.norm(m,n), args)              | (Op.Norm(Ty.TensorTy[m,n]), args) => CL.E_Apply(N.norm(m,n), args)
171              | (Op.Normalize d, args) => CL.E_Apply(N.normalize d, args)              | (Op.Normalize d, args) => CL.E_Apply(N.normalize d, args)
172              | (Op.Scale(Ty.TensorTy[n]), args) => CL.E_Apply(N.scale n, args)              | (Op.Scale(Ty.TensorTy[n]), args) => CL.E_Apply(N.scale n, args)
173              | (Op.PrincipleEvec ty, _) => raise Fail "PrincipleEvec unimplemented"              | (Op.PrincipleEvec ty, _) => raise Fail "PrincipleEvec unimplemented"
174              | (Op.Subscript(Ty.IVecTy n), [v, ix]) => let              | (Op.Subscript(Ty.SeqTy(Ty.IntTy, n)), [v, ix]) => let
175                  val unionTy = CL.T_Named(concat["union", Int.toString n, !N.gIntSuffix, "_t"])                  val unionTy = CL.T_Named(concat["union", Int.toString n, !N.gIntSuffix, "_t"])
176                  val vecExp = CL.mkSelect(CL.mkCast(unionTy, v), "i")                  val vecExp = CL.mkSelect(CL.mkCast(unionTy, v), "i")
177                  in                  in

Legend:
Removed from v.1521  
changed lines
  Added in v.1522

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0