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

SCM Repository

[diderot] Annotation of /trunk/src/compiler/high-il/check-high-il.sml
ViewVC logotype

Annotation of /trunk/src/compiler/high-il/check-high-il.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 407 - (view) (download)
Original Path: trunk/src/compiler/high-il/check-ops.sml

1 : jhr 404 (* check-ops.sml
2 :     *
3 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4 :     * All rights reserved.
5 : jhr 407 *
6 :     * Return the signature of a HighIL operator.
7 : jhr 404 *)
8 :    
9 : jhr 405 structure CheckOps : OPERATOR_TY = struct
10 : jhr 404
11 :     structure Op = HighOps
12 :     structure Ty = HighILTypes
13 :    
14 : jhr 405 type rator = Op.rator
15 :     type ty = Ty.ty
16 :    
17 : jhr 404 fun sign rator = (case rator
18 :     of Op.Add ty => (ty, [ty, ty])
19 :     | Op.Sub ty => (ty, [ty, ty])
20 :     | Op.Mul ty => (ty, [ty, ty])
21 :     | Op.Div ty => (ty, [ty, ty])
22 :     | Op.Neg ty => (ty, [ty])
23 :     | Op.LT ty => (Ty.BoolTy, [ty, ty])
24 :     | Op.LTE ty => (Ty.BoolTy, [ty, ty])
25 :     | Op.EQ ty => (Ty.BoolTy, [ty, ty])
26 :     | Op.NEQ ty => (Ty.BoolTy, [ty, ty])
27 :     | Op.GT ty => (Ty.BoolTy, [ty, ty])
28 :     | Op.GTE ty => (Ty.BoolTy, [ty, ty])
29 :     | Op.Max => (Ty.realTy, [Ty.realTy, Ty.realTy])
30 :     | Op.Min => (Ty.realTy, [Ty.realTy, Ty.realTy])
31 :     | Op.Sin => (Ty.realTy, [Ty.realTy])
32 :     | Op.Cos => (Ty.realTy, [Ty.realTy])
33 :     | Op.Pow => (Ty.realTy, [Ty.realTy, Ty.realTy])
34 :     | Op.Not => (Ty.BoolTy, [Ty.BoolTy])
35 :     | Op.Dot ty => (Ty.realTy, [ty, ty])
36 :     | Op.Cross => (Ty.vec3Ty, [Ty.vec3Ty, Ty.vec3Ty])
37 :     | Op.Norm => (Ty.realTy, [ty])
38 :     | Op.Scale ty => (ty, [Ty.realTy, ty])
39 :     | Op.InvScale ty => (ty, [ty, Ty.realTy])
40 : jhr 407 | Op.CL => (Ty.realTy, [Ty.TensorTy[3, 3]])
41 :     | Op.PrincipleEvec(resTy as Ty.TensorTy[d]) => (resTy, [Ty.TensorTy[d,d]])
42 :     | Op.Slice(ty as Ty.TensorTy dd, m) => let
43 : jhr 404 val (resDims, idxDims) = let
44 :     fun f (d, false, (rds, ids)) = (d::rds, ids)
45 :     | f (_, true, (rds, ids)) = (rds, Ty.IntTy::ids)
46 :     in
47 :     ListPair.foldr f ([], []) (dd, mask)
48 :     end
49 :     in
50 :     (Ty.Tensor rds, ty::idxDims)
51 :     end
52 : jhr 407 | Op.Subscript(ty as Ty.TensorTy dd) =>
53 : jhr 404 (Ty.realTy, ty :: List.map (fn _ => Ty.IntTy) dd)
54 :     | Op.IntToReal => (Ty.realTy, [Ty.IntTy])
55 :     | Op.TruncToInt => (Ty.IntTy, [Ty.realTy])
56 :     | Op.RoundToInt => (Ty.IntTy, [Ty.realTy])
57 :     | Op.CeilToInt => (Ty.IntTy, [Ty.realTy])
58 :     | Op.FloorToInt => (Ty.IntTy, [Ty.realTy])
59 :     | Op.Kernel _ => (Ty.KernelTy, [])
60 :     | Op.LoadImage _ => (Ty.ImageTy, [])
61 : jhr 407 | Op.Convolve => (Ty.FieldTy, [Ty.ImageTy, Ty.KernelTy])
62 :     (* FIXME: need dimension of vector *)
63 :     | Op.Inside => (Ty.BoolTy, ??)
64 : jhr 404 | Op.Field _ => (Ty.FieldTy, [])
65 :     | Op.AddField => (Ty.FieldTy, [Ty.FieldTy, Ty.FieldTy])
66 :     | Op.ScaleField => (Ty.FieldTy, [Ty.realTy, Ty.FieldTy])
67 :     | Op.NegField => (Ty.FieldTy, [Ty.FieldTy])
68 :     | Op.DiffField => (Ty.FieldTy, [Ty.FieldTy])
69 : jhr 407 (* FIXME: need dimension of position vector and shape of range *)
70 : jhr 404 | Op.Probe => ??
71 :     | Op.Input of string
72 :     | Op.InputWithDefault of string
73 :     (* end case *))
74 :    
75 :     end
76 : jhr 405
77 :     structure CheckHighIL = CheckILFn (
78 :     structure IL = HighIL
79 :     structure OpTy = CheckOps)

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