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

SCM Repository

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

Diff of /branches/vis12/src/compiler/low-il/check-low-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 14  Line 14 
14    
15      val vec3Ty = Ty.vecTy 3      val vec3Ty = Ty.vecTy 3
16    
17      (* utility function for synthesizing eigenvector/eigenvalue signature *)
18        fun eigenSig dim = let
19              val tplTy = Ty.TupleTy[
20                      Ty.SeqTy(Ty.realTy, dim),
21                      Ty.SeqTy(Ty.vecTy dim, dim)
22                    ]
23              in
24                (tplTy, [Ty.TensorTy[dim, dim]])
25              end
26    
27    (* Return the signature of a LowIL operator. *)    (* Return the signature of a LowIL operator. *)
28      fun sigOf rator = (case rator      fun sigOf rator = (case rator
29             of Op.Add(Ty.AddrTy rTy) => (Ty.AddrTy rTy, [Ty.AddrTy rTy, Ty.intTy])             of Op.Add(Ty.AddrTy rTy) => (Ty.AddrTy rTy, [Ty.AddrTy rTy, Ty.intTy])
# Line 40  Line 50 
50              | Op.MulMatVec(d1, d2) => (Ty.vecTy d1, [Ty.TensorTy[d1, d2], Ty.vecTy d2])              | Op.MulMatVec(d1, d2) => (Ty.vecTy d1, [Ty.TensorTy[d1, d2], Ty.vecTy d2])
51              | Op.MulMatMat(d1, d2, d3) => (Ty.TensorTy[d1, d3], [Ty.TensorTy[d1, d2], Ty.TensorTy[d2, d3]])              | Op.MulMatMat(d1, d2, d3) => (Ty.TensorTy[d1, d3], [Ty.TensorTy[d1, d2], Ty.TensorTy[d2, d3]])
52              | Op.Cross => (vec3Ty, [vec3Ty, vec3Ty])              | Op.Cross => (vec3Ty, [vec3Ty, vec3Ty])
             | Op.Select(ty as Ty.IVecTy 1, _) => raise Fail("sigOf: invalid operator " ^ Op.toString rator)  
             | Op.Select(ty as Ty.IVecTy d, _) => (Ty.intTy, [ty])  
             | Op.Select(ty as Ty.TensorTy[d], _) => (Ty.realTy, [ty])  
53              | Op.Norm(ty as Ty.TensorTy _) => (Ty.realTy, [ty])              | Op.Norm(ty as Ty.TensorTy _) => (Ty.realTy, [ty])
54              | Op.Normalize d => (Ty.vecTy d, [Ty.vecTy d])              | Op.Normalize d => (Ty.vecTy d, [Ty.vecTy d])
55              | Op.Scale(ty as Ty.TensorTy(_::_)) => (ty, [Ty.realTy, ty])              | Op.Scale(ty as Ty.TensorTy(_::_)) => (ty, [Ty.realTy, ty])
56              | Op.PrincipleEvec _ => raise Fail "Op.PrincipleEvec unimplemented"              | Op.PrincipleEvec _ => raise Fail "Op.PrincipleEvec unimplemented"
57                | Op.EigenVecs2x2 => eigenSig 2
58                | Op.EigenVecs3x3 => eigenSig 3
59                | Op.EigenVals2x2 => (Ty.SeqTy(Ty.realTy, 2), [Ty.TensorTy[2,2]])
60                | Op.EigenVals3x3 => (Ty.SeqTy(Ty.realTy, 3), [Ty.TensorTy[3,3]])
61              | Op.Identity d => (Ty.TensorTy[d,d], [])              | Op.Identity d => (Ty.TensorTy[d,d], [])
62              | Op.Zero ty => (ty, [])              | Op.Zero ty => (ty, [])
63              | Op.Subscript(Ty.IVecTy d) => (Ty.intTy, [Ty.IVecTy d, Ty.intTy])              | Op.Select(ty as Ty.TupleTy tys, i) => (List.nth(tys, i-1), [ty])
64                | Op.Index(ty as Ty.TensorTy[d], _) => (Ty.realTy, [ty])
65                | Op.Index(ty as Ty.SeqTy(elemTy, _), _) => (elemTy, [ty])
66              | Op.Subscript(ty as Ty.TensorTy dd) => (Ty.realTy, ty :: List.map (fn _ => Ty.intTy) dd)              | Op.Subscript(ty as Ty.TensorTy dd) => (Ty.realTy, ty :: List.map (fn _ => Ty.intTy) dd)
67                | Op.Subscript(ty as Ty.SeqTy(elemTy, d)) => (elemTy, [ty, Ty.intTy])
68              | Op.Ceiling d => (Ty.vecTy d, [Ty.vecTy d])              | Op.Ceiling d => (Ty.vecTy d, [Ty.vecTy d])
69              | Op.Floor d => (Ty.vecTy d, [Ty.vecTy d])              | Op.Floor d => (Ty.vecTy d, [Ty.vecTy d])
70              | Op.Round d => (Ty.vecTy d, [Ty.vecTy d])              | Op.Round d => (Ty.vecTy d, [Ty.vecTy d])
71              | Op.Trunc d => (Ty.vecTy d, [Ty.vecTy d])              | Op.Trunc d => (Ty.vecTy d, [Ty.vecTy d])
72              | Op.IntToReal => (Ty.realTy, [Ty.intTy])              | Op.IntToReal => (Ty.realTy, [Ty.intTy])
73              | Op.RealToInt d => (Ty.IVecTy d, [Ty.vecTy d])              | Op.RealToInt 1 => (Ty.IntTy, [Ty.realTy])
74                | Op.RealToInt d => (Ty.SeqTy(Ty.IntTy, d), [Ty.TensorTy[d]])
75    (* FIXME: the type of RealToInt should be
76                | Op.RealToInt d => (Ty.SeqTy(Ty.IntTy, d), [Ty.SeqTy(Ty.realTy, d)])
77    *)
78              | Op.ImageAddress info => (Ty.AddrTy info, [Ty.ImageTy info])              | Op.ImageAddress info => (Ty.AddrTy info, [Ty.ImageTy info])
79              | Op.LoadVoxels(info, n) => (Ty.vecTy n, [Ty.AddrTy info])              | Op.LoadVoxels(info, n) => (Ty.vecTy n, [Ty.AddrTy info])
80              | Op.PosToImgSpace info => let              | Op.PosToImgSpace info => let
# Line 69  Line 87 
87              | Op.Inside(info, _) => (Ty.BoolTy, [Ty.vecTy(ImageInfo.dim info), Ty.ImageTy info])              | Op.Inside(info, _) => (Ty.BoolTy, [Ty.vecTy(ImageInfo.dim info), Ty.ImageTy info])
88              | Op.Input(ty, _, _) => (ty, [])              | Op.Input(ty, _, _) => (ty, [])
89              | Op.InputWithDefault(ty, _, _) => (ty, [ty])              | Op.InputWithDefault(ty, _, _) => (ty, [ty])
90                | Op.Print tys => (Ty.TupleTy[], tys)
91              | _ => raise Fail("sigOf: invalid operator " ^ Op.toString rator)              | _ => raise Fail("sigOf: invalid operator " ^ Op.toString rator)
92            (* end case *))            (* end case *))
93    
# Line 76  Line 95 
95        | typeOfCons (expectedTy, tys as ty1::_) =        | typeOfCons (expectedTy, tys as ty1::_) =
96            if List.all (fn ty => Ty.same(ty1, ty)) tys            if List.all (fn ty => Ty.same(ty1, ty)) tys
97              then (case (expectedTy, ty1)              then (case (expectedTy, ty1)
98                 of (Ty.IVecTy n, Ty.IVecTy 1) => (n = List.length tys)                 of (Ty.SeqTy(_, n), Ty.IntTy) => (n = List.length tys)
99                  | (Ty.TensorTy dd, Ty.TensorTy dd') => (dd = List.length tys :: dd')                  | (Ty.TensorTy dd, Ty.TensorTy dd') => (dd = List.length tys :: dd')
100                  | _ => false                  | _ => false
101                (* end case *))                (* end case *))

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