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

SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/high-il/check-high-il.sml
ViewVC logotype

Diff of /branches/vis12/src/compiler/high-il/check-high-il.sml

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

revision 1639, Wed Nov 16 01:48:07 2011 UTC revision 1640, Wed Nov 16 02:19:51 2011 UTC
# Line 12  Line 12 
12      type rator = Op.rator      type rator = Op.rator
13      type ty = Ty.ty      type ty = Ty.ty
14    
15      (* utility function for synthesizing eigenvector/eigenvalue signature *)
16        fun eigenSig dim = let
17              val tplTy = Ty.TupleTy[
18                      Ty.SeqTy(Ty.realTy, dim),
19                      Ty.SeqTy(Ty.vecTy dim, dim)
20                    ]
21              in
22                (tplTy, [Ty.TensorTy[dim, dim]])
23              end
24    
25    (* Return the signature of a HighIL operator. *)    (* Return the signature of a HighIL operator. *)
26      fun sigOf rator = (case rator      fun sigOf rator = (case rator
27             of Op.Add ty => (ty, [ty, ty])             of Op.Add ty => (ty, [ty, ty])
# Line 43  Line 53 
53              | Op.Normalize ty => (ty, [ty])              | Op.Normalize ty => (ty, [ty])
54              | Op.Scale ty => (ty, [Ty.realTy, ty])              | Op.Scale ty => (ty, [Ty.realTy, ty])
55              | Op.PrincipleEvec(resTy as Ty.TensorTy[d]) => (resTy, [Ty.TensorTy[d,d]])              | Op.PrincipleEvec(resTy as Ty.TensorTy[d]) => (resTy, [Ty.TensorTy[d,d]])
56                | Op.Eigen2x2 => eigenSig 2
57                | Op.Eigen3x3 => eigenSig 3
58              | Op.Identity d => (Ty.TensorTy[d,d], [])              | Op.Identity d => (Ty.TensorTy[d,d], [])
59              | Op.Zero ty => (ty, [])              | Op.Zero ty => (ty, [])
60              | Op.Trace ty => (Ty.realTy, [ty])              | Op.Trace ty => (Ty.realTy, [ty])
# Line 56  Line 68 
68                  in                  in
69                    (Ty.TensorTy resDims, ty::idxDims)                    (Ty.TensorTy resDims, ty::idxDims)
70                  end                  end
71              | Op.Subscript(ty as Ty.TensorTy dd) =>              | Op.TensorSub(ty as Ty.TensorTy dd) =>
72                  (Ty.realTy, ty :: List.map (fn _ => Ty.IntTy) dd)                  (Ty.realTy, ty :: List.map (fn _ => Ty.IntTy) dd)
73                | Op.Select(ty as Ty.TupleTy tys, i) =>
74                    if (1 <= i) andalso (i <= length tys)
75                      then (List.nth(tys, i-1), [ty])
76                      else raise Fail("sigOf: invalid operator " ^ Op.toString rator)
77                | Op.SeqSub(ty as Ty.SeqTy(elemTy, _)) => (elemTy, [ty, Ty.IntTy])
78              | Op.IntToReal => (Ty.realTy, [Ty.IntTy])              | Op.IntToReal => (Ty.realTy, [Ty.IntTy])
79              | Op.TruncToInt => (Ty.IntTy, [Ty.realTy])              | Op.TruncToInt => (Ty.IntTy, [Ty.realTy])
80              | Op.RoundToInt => (Ty.IntTy, [Ty.realTy])              | Op.RoundToInt => (Ty.IntTy, [Ty.realTy])
# Line 75  Line 92 
92              | Op.Probe(domTy, rngTy) => (rngTy, [Ty.FieldTy, domTy])              | Op.Probe(domTy, rngTy) => (rngTy, [Ty.FieldTy, domTy])
93              | Op.Input(ty, _, _) => (ty, [])              | Op.Input(ty, _, _) => (ty, [])
94              | Op.InputWithDefault(ty, _, _) => (ty, [ty])              | Op.InputWithDefault(ty, _, _) => (ty, [ty])
95                | Op.Print tys => (Ty.TupleTy[], tys)
96              | _ => raise Fail("sigOf: invalid operator " ^ Op.toString rator)              | _ => raise Fail("sigOf: invalid operator " ^ Op.toString rator)
97            (* end case *))            (* end case *))
98    

Legend:
Removed from v.1639  
changed lines
  Added in v.1640

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