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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/mid-to-low/mid-to-low.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/mid-to-low/mid-to-low.sml

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

revision 1301, Thu Jun 9 23:58:40 2011 UTC revision 1370, Wed Jun 22 21:11:20 2011 UTC
# Line 84  Line 84 
84      fun imul (r : DstIL.var, a, b) = (r, DstIL.OP(DstOp.Mul DstTy.intTy, [a, b]))      fun imul (r : DstIL.var, a, b) = (r, DstIL.OP(DstOp.Mul DstTy.intTy, [a, b]))
85      fun iadd (r : DstIL.var, a, b) = (r, DstIL.OP(DstOp.Add DstTy.intTy, [a, b]))      fun iadd (r : DstIL.var, a, b) = (r, DstIL.OP(DstOp.Add DstTy.intTy, [a, b]))
86      fun ilit (r : DstIL.var, n) = (r, DstIL.LIT(Literal.Int(IntInf.fromInt n)))      fun ilit (r : DstIL.var, n) = (r, DstIL.LIT(Literal.Int(IntInf.fromInt n)))
87        fun radd (r : DstIL.var, a, b) = (r, DstIL.OP(DstOp.Add DstTy.realTy, [a, b]))
88    
89    (* expand the EvalKernel operations into vector operations.  The parameters    (* expand the EvalKernel operations into vector operations.  The parameters
90     * are     * are
# Line 278  Line 279 
279              List.rev code              List.rev code
280            end            end
281    
282      (* expand trace(M) *)
283        fun expandTrace (y, d, [m]) = let
284              val matTy = DstTy.TensorTy[d,d]
285              val rowTy = DstTy.TensorTy[d]
286              fun f (i, dst) = if (i < d)
287                    then let
288                      val i' = Int.toString i
289                      val ix = DstIL.Var.new ("ix" ^ i', DstTy.intTy)
290                      val x = DstIL.Var.new ("x"  ^ i', DstTy.realTy)
291                      val acc = DstIL.Var.new ("acc" ^ i', DstTy.realTy)
292                      val stms = f (i+1, acc)
293                      in
294                        radd(dst, acc, x) ::
295                        (x, DstIL.OP(DstOp.Subscript(matTy), [m, ix, ix])) ::
296                        ilit(ix, i) ::
297                        stms
298                      end
299                    else let
300                      val ix = DstIL.Var.new ("ix" ^ Int.toString i, DstTy.intTy)
301                      in [
302                        (dst, DstIL.OP(DstOp.Subscript(matTy), [m, ix, ix])),
303                        ilit(ix, i)
304                      ] end
305              in
306                List.rev (f (1, y))
307              end
308    
309      fun expandOp (env, y, rator, args) = let      fun expandOp (env, y, rator, args) = let
310            val args' = renameList(env, args)            val args' = renameList(env, args)
311            fun assign rator' = [(y, DstIL.OP(rator', args'))]            fun assign rator' = [(y, DstIL.OP(rator', args'))]
# Line 313  Line 341 
341                | SrcOp.CL => assign (DstOp.CL)                | SrcOp.CL => assign (DstOp.CL)
342                | SrcOp.PrincipleEvec ty => assign (DstOp.PrincipleEvec ty)                | SrcOp.PrincipleEvec ty => assign (DstOp.PrincipleEvec ty)
343                | SrcOp.Identity n => assign (DstOp.Identity n)                | SrcOp.Identity n => assign (DstOp.Identity n)
344                | SrcOp.Trace d => assign (DstOp.Trace d)                | SrcOp.Trace d => expandTrace (y, d, args')
345                | SrcOp.Subscript ty => assign (DstOp.Subscript ty)                | SrcOp.Subscript ty => assign (DstOp.Subscript ty)
346                | SrcOp.Ceiling d => assign (DstOp.Ceiling d)                | SrcOp.Ceiling d => assign (DstOp.Ceiling d)
347                | SrcOp.Floor d => assign (DstOp.Floor d)                | SrcOp.Floor d => assign (DstOp.Floor d)

Legend:
Removed from v.1301  
changed lines
  Added in v.1370

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