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/ein-to-scalar.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/mid-to-low/ein-to-scalar.sml

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

revision 3710, Fri Apr 1 21:41:45 2016 UTC revision 3728, Wed Apr 6 20:05:42 2016 UTC
# Line 10  Line 10 
10    
11  structure EinToScalar : sig  structure EinToScalar : sig
12    
13      val expand :    (* expand a scalar-valued Ein operator application to LowIR code; return the LowIR
14            AvailRHS.t * int IntRedBlackMap.map * Ein.param_kind list * Ein.ein_exp * LowIR.var list     * vaiable that holds the result of the application (the assignments will be added
15              -> LowIR.var     * to avail).
16       *)
17        val expand : {
18                avail : AvailRHS.t,                 (* the generated LowIR assignments *)
19                mapp : int IntRedBlackMap.map,      (* mapping from deBruijn indices to argument IDs *)
20                params : Ein.param_kind list,       (* formal parameters of Ein operator *)
21                body : Ein.ein_exp,                 (* the EIN operator body *)
22                midArgs : MidIR.var list,           (* MidIR arguments to Ein operator *)
23                lowArgs : LowIR.var list            (* corresponding LowIR arguments *)
24              } -> LowIR.var
25    
26    end = struct    end = struct
27    
# Line 30  Line 39 
39            (* end case *))            (* end case *))
40    
41  (* FIXME: we probably do not need the params (depending on how we implement FieldToLow.expand *)  (* FIXME: we probably do not need the params (depending on how we implement FieldToLow.expand *)
42      fun expand (avail, mapp, params, body, args) = let      fun expand {avail, mapp, params, body, midArgs, lowArgs} = let
43            fun gen (mapp, body) = let            fun gen (mapp, body) = let
44                (*********sumexpression ********)                (*********sumexpression ********)
45                  fun tb n =  List.tabulate (n, fn e => e)                  fun tb n =  List.tabulate (n, fn e => e)
# Line 68  Line 77 
77                      | E.Delta(i, j) => Mk.delta (avail, mapp, i, j)                      | E.Delta(i, j) => Mk.delta (avail, mapp, i, j)
78                      | E.Epsilon(i, j, k) => Mk.epsilon3 (avail, mapp, i, j, k)                      | E.Epsilon(i, j, k) => Mk.epsilon3 (avail, mapp, i, j, k)
79                      | E.Eps2(i, j) => Mk.epsilon2 (avail, mapp, i, j)                      | E.Eps2(i, j) => Mk.epsilon2 (avail, mapp, i, j)
80                      | E.Tensor(id, ix) => Mk.tensorIndex (avail, mapp, List.nth(args, id), ix)                      | E.Tensor(id, ix) => Mk.tensorIndex (avail, mapp, List.nth(lowArgs, id), ix)
81                      | E.Op1(op1, e1) => let                      | E.Op1(op1, e1) => let
82                          val arg = gen (mapp, e1)                          val arg = gen (mapp, e1)
83                          in                          in
# Line 98  Line 107 
107                      | E.Op2(E.Div, e1 as E.Tensor (_, [_]), e2 as E.Tensor (_, [])) =>                      | E.Op2(E.Div, e1 as E.Tensor (_, [_]), e2 as E.Tensor (_, [])) =>
108                          gen (mapp, E.Opn(E.Prod, [E.Op2 (E.Div, E.Const 1, e2), e1]))                          gen (mapp, E.Opn(E.Prod, [E.Op2 (E.Div, E.Const 1, e2), e1]))
109                      | E.Op2(E.Div, e1, e2) => Mk.realDiv (avail, gen (mapp, e1), gen (mapp, e2))                      | E.Op2(E.Div, e1, e2) => Mk.realDiv (avail, gen (mapp, e1), gen (mapp, e2))
110                      | E.Sum(x, E.Opn (E.Prod, (E.Img (Vid, _, _) :: E.Krn (Hid, _, _) ::_))) =>                      | E.Sum(sx, E.Opn(E.Prod, prod as (E.Img(Vid, _, _) :: E.Krn(Hid, _, _) ::_))) =>
111  (*                          FieldToLow.expand {
112                          FieldToLow.expand (avail, mapp, params, body, args)                              avail = avail, mapp = mapp,
113  *)                              sx = sx, prod = prod,
114  raise Fail "FIXME: unimplemented"                              params = params, (* FIXME: do we need these? *)
115                                midArgs = midArgs, lowArgs = lowArgs
116                              }
117                      | E.Sum(sumx, e) =>                      | E.Sum(sumx, e) =>
118                          Mk.reduce (avail, Mk.realAdd, sumCheck (mapp, sumx, e))                          Mk.reduce (avail, Mk.realAdd, sumCheck (mapp, sumx, e))
119                      | _ => raise Fail("unsupported ein-exp: " ^ EinPP.expToString body)                      | _ => raise Fail("unsupported ein-exp: " ^ EinPP.expToString body)

Legend:
Removed from v.3710  
changed lines
  Added in v.3728

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