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 405 - (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 :     *)
6 :    
7 : jhr 405 structure CheckOps : OPERATOR_TY = struct
8 : jhr 404
9 :     structure Op = HighOps
10 :     structure Ty = HighILTypes
11 :    
12 : jhr 405 type rator = Op.rator
13 :     type ty = Ty.ty
14 :    
15 : jhr 404 fun sign rator = (case rator
16 :     of Op.Add ty => (ty, [ty, ty])
17 :     | Op.Sub ty => (ty, [ty, ty])
18 :     | Op.Mul ty => (ty, [ty, ty])
19 :     | Op.Div ty => (ty, [ty, ty])
20 :     | Op.Neg ty => (ty, [ty])
21 :     | Op.LT ty => (Ty.BoolTy, [ty, ty])
22 :     | Op.LTE ty => (Ty.BoolTy, [ty, ty])
23 :     | Op.EQ ty => (Ty.BoolTy, [ty, ty])
24 :     | Op.NEQ ty => (Ty.BoolTy, [ty, ty])
25 :     | Op.GT ty => (Ty.BoolTy, [ty, ty])
26 :     | Op.GTE ty => (Ty.BoolTy, [ty, ty])
27 :     | Op.Max => (Ty.realTy, [Ty.realTy, Ty.realTy])
28 :     | Op.Min => (Ty.realTy, [Ty.realTy, Ty.realTy])
29 :     | Op.Sin => (Ty.realTy, [Ty.realTy])
30 :     | Op.Cos => (Ty.realTy, [Ty.realTy])
31 :     | Op.Pow => (Ty.realTy, [Ty.realTy, Ty.realTy])
32 :     | Op.Not => (Ty.BoolTy, [Ty.BoolTy])
33 :     | Op.Dot ty => (Ty.realTy, [ty, ty])
34 :     | Op.Cross => (Ty.vec3Ty, [Ty.vec3Ty, Ty.vec3Ty])
35 :     | Op.Norm => (Ty.realTy, [ty])
36 :     | Op.Scale ty => (ty, [Ty.realTy, ty])
37 :     | Op.InvScale ty => (ty, [ty, Ty.realTy])
38 :     | Op.CL =>
39 :     | Op.PrincipleEvec ty => (Ty.realTy, [ty])
40 :     | Op.Slice(ty as Ty.Tensor dd, m) => let
41 :     val (resDims, idxDims) = let
42 :     fun f (d, false, (rds, ids)) = (d::rds, ids)
43 :     | f (_, true, (rds, ids)) = (rds, Ty.IntTy::ids)
44 :     in
45 :     ListPair.foldr f ([], []) (dd, mask)
46 :     end
47 :     in
48 :     (Ty.Tensor rds, ty::idxDims)
49 :     end
50 :     | Op.Subscript(ty as Ty.Tensor dd) =>
51 :     (Ty.realTy, ty :: List.map (fn _ => Ty.IntTy) dd)
52 :     | Op.IntToReal => (Ty.realTy, [Ty.IntTy])
53 :     | Op.TruncToInt => (Ty.IntTy, [Ty.realTy])
54 :     | Op.RoundToInt => (Ty.IntTy, [Ty.realTy])
55 :     | Op.CeilToInt => (Ty.IntTy, [Ty.realTy])
56 :     | Op.FloorToInt => (Ty.IntTy, [Ty.realTy])
57 :     | Op.Kernel _ => (Ty.KernelTy, [])
58 :     | Op.LoadImage _ => (Ty.ImageTy, [])
59 :     | Op.Convolve =>
60 :     | Op.Inside =>
61 :     | Op.Field _ => (Ty.FieldTy, [])
62 :     | Op.AddField => (Ty.FieldTy, [Ty.FieldTy, Ty.FieldTy])
63 :     | Op.ScaleField => (Ty.FieldTy, [Ty.realTy, Ty.FieldTy])
64 :     | Op.NegField => (Ty.FieldTy, [Ty.FieldTy])
65 :     | Op.DiffField => (Ty.FieldTy, [Ty.FieldTy])
66 :     | Op.Probe => ??
67 :     | Op.Input of string
68 :     | Op.InputWithDefault of string
69 :     (* end case *))
70 :    
71 :     end
72 : jhr 405
73 :     structure CheckHighIL = CheckILFn (
74 :     structure IL = HighIL
75 :     structure OpTy = CheckOps)

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