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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/cl-target/tree-to-cl.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/cl-target/tree-to-cl.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 53  Line 53 
53      fun trType ty = (case ty      fun trType ty = (case ty
54             of Ty.BoolTy => CLang.T_Named "bool"             of Ty.BoolTy => CLang.T_Named "bool"
55              | Ty.StringTy => CL.charPtr              | Ty.StringTy => CL.charPtr
56              | Ty.IVecTy 1 => !RN.gIntTy              | Ty.IntTy => !RN.gIntTy
             | Ty.IVecTy n => CL.T_Named(RN.ivecTy n)  
57              | Ty.TensorTy[] => !RN.gRealTy              | Ty.TensorTy[] => !RN.gRealTy
58              | Ty.TensorTy[n] => CL.T_Named(RN.vecTy n)              | Ty.TensorTy[n] => CL.T_Named(RN.vecTy n)
59              | Ty.TensorTy[n, m] => CL.T_Named(RN.matTy(n,m))              | Ty.TensorTy[n, m] => CL.T_Named(RN.matTy(n,m))
60                | Ty.SeqTy(Ty.IntTy, n) => CL.T_Named(RN.ivecTy n)
61                | Ty.SeqTy(Ty.TensorTy[] , n) => CL.T_Named(RN.vecTy n)
62              | Ty.AddrTy(ImageInfo.ImgInfo{ty=(_, rTy), ...}) => imageDataPtrTy rTy              | Ty.AddrTy(ImageInfo.ImgInfo{ty=(_, rTy), ...}) => imageDataPtrTy rTy
63              | Ty.ImageTy(ImageInfo.ImgInfo{dim, ...}) => CL.T_Named(RN.imageTy dim)              | Ty.ImageTy(ImageInfo.ImgInfo{dim, ...}) => CL.T_Named(RN.imageTy dim)
64              | _ => raise Fail(concat["TreeToC.trType(", Ty.toString ty, ")"])              | _ => raise Fail(concat["TreeToC.trType(", Ty.toString ty, ")"])
# Line 110  Line 111 
111              | (Op.Mul ty, [a, b]) => CL.mkBinOp(a, CL.#*, b)              | (Op.Mul ty, [a, b]) => CL.mkBinOp(a, CL.#*, b)
112              | (Op.Div ty, [a, b]) => CL.mkBinOp(a, CL.#/, b)              | (Op.Div ty, [a, b]) => CL.mkBinOp(a, CL.#/, b)
113              | (Op.Neg ty, [a]) => CL.mkUnOp(CL.%-, a)              | (Op.Neg ty, [a]) => CL.mkUnOp(CL.%-, a)
114              | (Op.Abs(Ty.IVecTy 1), args) => CL.mkApply("abs", args)              | (Op.Abs(Ty.IntTy), args) => CL.mkApply("abs", args)
115              | (Op.Abs(Ty.TensorTy[]), args) => CL.mkApply(RN.fabs, args)              | (Op.Abs(Ty.TensorTy[]), args) => CL.mkApply(RN.fabs, args)
116              | (Op.Abs(Ty.TensorTy[_]), args) => CL.mkApply(RN.fabs, args)              | (Op.Abs(Ty.TensorTy[_]), args) => CL.mkApply(RN.fabs, args)
117              | (Op.Abs ty, [a]) => raise Fail(concat["Abs<", Ty.toString ty, ">"])              | (Op.Abs ty, [a]) => raise Fail(concat["Abs<", Ty.toString ty, ">"])
# Line 145  Line 146 
146                    then CL.E_Apply(RN.mulMatMat(m,n,p), args)                    then CL.E_Apply(RN.mulMatMat(m,n,p), args)
147                    else raise Fail "unsupported matrix-matrix multiply"                    else raise Fail "unsupported matrix-matrix multiply"
148              | (Op.Cross, args) => CL.E_Apply(RN.cross, args)              | (Op.Cross, args) => CL.E_Apply(RN.cross, args)
149              | (Op.Select(Ty.IVecTy n, i), [a]) => vecIndex (a, i)              | (Op.Select(Ty.SeqTy(Ty.IntTy, n), i), [a]) => vecIndex (a, i)
150              | (Op.Select(Ty.TensorTy[n], i), [a]) => vecIndex (a, i)              | (Op.Select(Ty.TensorTy[n], i), [a]) => vecIndex (a, i)
151              | (Op.Norm(Ty.TensorTy[n]), args) => CL.E_Apply(RN.length, args)              | (Op.Norm(Ty.TensorTy[n]), args) => CL.E_Apply(RN.length, args)
152              | (Op.Norm(Ty.TensorTy[m,n]), args) => CL.E_Apply(RN.norm(m,n), args)              | (Op.Norm(Ty.TensorTy[m,n]), args) => CL.E_Apply(RN.norm(m,n), args)
153              | (Op.Normalize d, args) => CL.E_Apply(RN.normalize, args)              | (Op.Normalize d, args) => CL.E_Apply(RN.normalize, args)
154              | (Op.Scale(Ty.TensorTy[n]), [s, v]) => CL.mkBinOp(s, CL.#*, v)              | (Op.Scale(Ty.TensorTy[n]), [s, v]) => CL.mkBinOp(s, CL.#*, v)
155              | (Op.PrincipleEvec ty, _) => raise Fail "PrincipleEvec unimplemented"              | (Op.PrincipleEvec ty, _) => raise Fail "PrincipleEvec unimplemented"
156              | (Op.Subscript(Ty.IVecTy n), [v, CL.E_Int(ix, _)]) => vecIndex (v, Int.fromLarge ix)              | (Op.Subscript(Ty.SeqTy(Ty.IntTy, n)), [v, CL.E_Int(ix, _)]) => vecIndex (v, Int.fromLarge ix)
157              | (Op.Subscript(Ty.IVecTy n), [v, ix]) => let              | (Op.Subscript(Ty.SeqTy(Ty.IntTy, n)), [v, ix]) => let
158                  val unionTy = CL.T_Named(concat["union", Int.toString n, !RN.gIntSuffix, "_t"])                  val unionTy = CL.T_Named(concat["union", Int.toString n, !RN.gIntSuffix, "_t"])
159                  val vecExp = CL.mkSelect(CL.mkCast(unionTy, v), "i")                  val vecExp = CL.mkSelect(CL.mkCast(unionTy, v), "i")
160                  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