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

SCM Repository

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

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

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

revision 2666, Wed Jun 4 01:59:49 2014 UTC revision 2667, Thu Jun 5 18:54:12 2014 UTC
# Line 138  Line 138 
138      fun matIndex (m, ix, jx) =      fun matIndex (m, ix, jx) =
139            CL.mkSubscript(CL.mkSelect(CL.mkSubscript(m, ix), "r"), jx)            CL.mkSubscript(CL.mkSelect(CL.mkSubscript(m, ix), "r"), jx)
140    
141        fun matProj(m, ix) =
142         CL.mkSelect(CL.mkSubscript(m, ix), "r")
143    
144    (* Translate a TreeIL operator application to a CLang expression *)    (* Translate a TreeIL operator application to a CLang expression *)
145      fun trOp (rator, args) = (case (rator, args)      fun trOp (rator, args) = (case (rator, args)
146             of (Op.IAdd , [a, b]) => CL.mkBinOp(a, CL.#+, b)             of (Op.IAdd , [a, b]) => CL.mkBinOp(a, CL.#+, b)
# Line 153  Line 156 
156              | (Op.addVec n,[a,b])    => CL.mkBinOp(a, CL.#+, b)              | (Op.addVec n,[a,b])    => CL.mkBinOp(a, CL.#+, b)
157              | (Op.prodVec n,[a, b])   => CL.mkBinOp(a, CL.#*, b)              | (Op.prodVec n,[a, b])   => CL.mkBinOp(a, CL.#*, b)
158    
159                |(Op.Sqrt ,[a])=>       CL.E_Sqrt a
160    
161               (*Vector functions*)               (*Vector functions*)
162              | (Op.prodScaV d,args)   => CL.E_Apply(N.NameScaV d, args)              | (Op.prodScaV d,args)   => CL.E_Apply(N.NameScaV d, args)
163              | (Op.sumVec d,args)     => CL.E_Apply(N.NameSumV d, args)              | (Op.sumVec d,args)     => CL.E_Apply(N.NameSumV d, args)
164              | (Op.IndexTensor(_,Ty.TensorTy [], Ty.indexTy [i],  Ty.TensorTy [argTy]),[a])=>              | (Op.IndexTensor(_,Ty.TensorTy [], Ty.indexTy [i],  Ty.TensorTy [argTy]),[a])=>
165                      vecIndex (a, argTy, i)                      vecIndex (a, argTy, i)
166    
167                | (Op.IndexTensor (_,Ty.TensorTy [_], Ty.indexTy [i],
168                    Ty.TensorTy[_,_]),[m])=>matProj(m,intExp i)
169                | (Op.IndexTensor (_,Ty.TensorTy [], Ty.indexTy [i,j],
170                    Ty.TensorTy[_,_]),[m])=>
171                        matIndex (m, intExp i, intExp   j)
172    
173              | (Op.IndexTensor (_,rstTy, Ty.indexTy indexAt, argTy),args)=>  raise Fail"Not sure how to index higher-order tensors"              | (Op.IndexTensor (_,rstTy, Ty.indexTy indexAt, argTy),args)=>  raise Fail"higer tensor "
174             (*             (*
175   | (Op.imgAddr of ImageInfo.info * ty * int   | (Op.imgAddr of ImageInfo.info * ty * int
176   | (Op.imgLoad of ImageInfo.info * int * int   | (Op.imgLoad of ImageInfo.info * int * int
# Line 190  Line 200 
200                  (* end case *))                  (* end case *))
201    
202    
203              | (Op.Norm(Ty.TensorTy[n]), args) => CL.E_Apply(N.length n, args)           (*
204              | (Op.Norm(Ty.TensorTy[m,n]), args) => CL.E_Apply(N.normMat(m,n), args)              | (Op.Norm(Ty.TensorTy[n]), args) =>raise Fail "Norm Vector:should have been removed in mid-to-low"
205                | (Op.Norm(Ty.TensorTy[m,n]), args) => raise Fail "Norm Mat:should have been removed in mid-to-low"
206              | (Op.Normalize d, args) => CL.E_Apply(N.normalize d, args)              | (Op.Normalize d, args) => CL.E_Apply(N.normalize d, args)
207    
208            *)
209    
210              | (Op.PrincipleEvec ty, _) => raise Fail "PrincipleEvec unimplemented"              | (Op.PrincipleEvec ty, _) => raise Fail "PrincipleEvec unimplemented"
211              | (Op.Select(Ty.TupleTy tys, i), [a]) => raise Fail "Select unimplemented"              | (Op.Select(Ty.TupleTy tys, i), [a]) => raise Fail "Select unimplemented"
212              | (Op.Index(Ty.SeqTy(Ty.IntTy, n), i), [a]) => ivecIndex (a, n, i)              | (Op.Index(Ty.SeqTy(Ty.IntTy, n), i), [a]) => ivecIndex (a, n, i)

Legend:
Removed from v.2666  
changed lines
  Added in v.2667

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