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

SCM Repository

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

Diff of /branches/vis15/src/compiler/mid-to-low/mk-low-ir.sml

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

revision 3660, Thu Feb 4 20:33:08 2016 UTC revision 3661, Fri Feb 5 00:45:24 2016 UTC
# Line 19  Line 19 
19      val realLit : AvailRHS.t * RealLit.t -> LowIR.var      val realLit : AvailRHS.t * RealLit.t -> LowIR.var
20    (* make "x := <real-literal>", where the real literal is specified as an integer *)    (* make "x := <real-literal>", where the real literal is specified as an integer *)
21      val intToRealLit : AvailRHS.t * int -> LowIR.var      val intToRealLit : AvailRHS.t * int -> LowIR.var
22    
23      (* generate a reduction sequence using the given binary operator *)
24        val reduce : AvailRHS.t * (AvailRHS.t * LowIR.var * LowIR.var -> LowIR.var) * LowIR.var list
25              -> LowIR.var
26    
27      (* scalar arithmetic *)
28        val realAdd : AvailRHS.t * LowIR.var * LowIR.var -> LowIR.var
29        val realSub : AvailRHS.t * LowIR.var * LowIR.var -> LowIR.var
30        val realMul : AvailRHS.t * LowIR.var * LowIR.var -> LowIR.var
31        val realDiv : AvailRHS.t * LowIR.var * LowIR.var -> LowIR.var
32        val realNeg : AvailRHS.t * LowIR.var -> LowIR.var
33    
34    (* make "x := [args]" *)    (* make "x := [args]" *)
35      val cons : AvailRHS.t * int list * LowIR.var list -> LowIR.var      val cons : AvailRHS.t * int list * LowIR.var list -> LowIR.var
36    (* code for δ_{i,j} *)    (* code for δ_{i,j} *)
# Line 48  Line 60 
60      fun intLit (avail, n) = add (avail, "intLit", Ty.intTy, IR.LIT(Literal.Int n))      fun intLit (avail, n) = add (avail, "intLit", Ty.intTy, IR.LIT(Literal.Int n))
61      fun realLit (avail, r) = add (avail, "realLit", Ty.realTy, IR.LIT(Literal.Real r))      fun realLit (avail, r) = add (avail, "realLit", Ty.realTy, IR.LIT(Literal.Real r))
62      fun intToRealLit (avail, n) = realLit (avail, RealLit.fromInt(IntInf.fromInt n))      fun intToRealLit (avail, n) = realLit (avail, RealLit.fromInt(IntInf.fromInt n))
63    
64      fun cons (avail, shp, args) = add (avail, "tensor", Ty.TensorTy shp, IR.CONS(args, Ty.TensorTy shp))      fun cons (avail, shp, args) = add (avail, "tensor", Ty.TensorTy shp, IR.CONS(args, Ty.TensorTy shp))
65    
66      (* scalar arithmetic *)
67        local
68          fun scalarOp2 rator (avail, x, y) = add (avail, "r", Ty.realTy, IR.OP(rator, [x, y]))
69        in
70        val realAdd = scalarOp2 Op.RAdd
71        val realSub = scalarOp2 Op.RSub
72        val realMul = scalarOp2 Op.RMul
73        val realDiv = scalarOp2 Op.RDiv
74        fun realNeg (avail, x) = add (avail, "r", Ty.realTy, IR.OP(Op.RNeg, [x]))
75        end (* local *)
76    
77        fun reduce (avail, rator, []) = raise Fail "reduction with no arguments"
78          | reduce (avail, rator, arg::args) = let
79              fun gen (acc, []) = acc
80                | gen (acc, x::xs) = gen (rator (avail, acc, x), xs)
81              in
82                gen (arg, args)
83              end
84    
85      local      local
86        fun lookupMu (mapp, E.V id) = (case IMap.find (mapp, id)        fun lookupMu (mapp, E.V id) = (case IMap.find (mapp, id)
87               of SOME n => n               of SOME n => n

Legend:
Removed from v.3660  
changed lines
  Added in v.3661

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