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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 184 - (view) (download)

1 : jhr 166 (* high-il.sml
2 :     *
3 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *
6 :     * High-level version of the Diderot IL.
7 :     *)
8 :    
9 :     structure HighOps =
10 :     struct
11 :    
12 : jhr 180 type ty = BoolTy | StringTy | IntTy | TensorTy of int list
13 : jhr 166
14 :     fun sameTy (ty1 : ty, ty2) = (ty1 = ty2)
15 :    
16 :     datatype rator
17 :     = Add of ty | Sub of ty (* type-indexed arithmetic operations *)
18 :     | Mul of ty | Div of ty
19 :     | Neg of ty
20 : jhr 180 | LT of ty | LTE of ty
21 :     | EQ of ty | NEQ of ty
22 :     | GT of ty | GTE of ty
23 : jhr 166 | Dot of ty | Cross | Norm of ty (* vector operations *)
24 : jhr 184 | Scale of ty (* scalar*tensor multiplication *)
25 :     | InvScale of ty (* tensor/scalar division *)
26 : jhr 166 | CL (* linear anisotropy measure *)
27 :     | PrincipleEvec (* principle eigenvector *)
28 :     | Subscript of ty
29 :     | Max | Min
30 :     | Sin | Cos
31 :     | Pow
32 : jhr 180 | Not (* boolean negation *)
33 : jhr 166 (* conversions *)
34 :     | IntToReal
35 :     | TruncToInt
36 :     | RoundToInt
37 :     | CeilToInt
38 :     | FloorToInt
39 :     (* image/field operations *)
40 :     | LoadImage of ImageInfo.info (* image-file loading *)
41 :     | Inside
42 :     | Field of FieldDef.field_def
43 :     | Probe
44 :     | Transform of ImageInfo.info (* transform to image-space *)
45 :    
46 :     fun arity (Add _) = 2
47 :     | arity (Sub _) = 2
48 :     | arity (Mul _) = 2
49 :     | arity (Div _) = 2
50 :     | arity (Neg _) = 1
51 : jhr 180 | arity (LT _) = 2
52 :     | arity (LTE _) = 2
53 :     | arity (EQ _) = 2
54 :     | arity (NEQ _) = 2
55 :     | arity (GT _) = 2
56 :     | arity (GTE _) = 2
57 : jhr 166 | arity (Dot _) = 2
58 :     | arity Cross = 2
59 :     | arity (Norm _) = 1
60 :     | arity (Scale _) = 2
61 :     | arity CL = 2
62 :     | arity PrincipleEvec = 1
63 :     | arity (Subscript _) = 2
64 :     | arity Max = 1
65 :     | arity Min = 1
66 :     | arity Sin = 1
67 :     | arity Cos = 1
68 :     | arity Pow = 2
69 : jhr 180 | arity Not = 1
70 : jhr 166 | arity IntToReal = 1
71 :     | arity TruncToInt = 1
72 :     | arity RoundToInt = 1
73 :     | arity CeilToInt = 1
74 :     | arity FloorToInt = 1
75 :     | arity (LoadImage _) = 1
76 :     | arity Inside = 2
77 :     | arity (Field _) = 0
78 :     | arity Probe = 2
79 :     | arity (Transform _) = 1
80 :    
81 :     fun same (Add ty1, Add ty2) = sameTy(ty1, ty2)
82 :     | same (Sub ty1, Sub ty2) = sameTy(ty1, ty2)
83 :     | same (Mul ty1, Mul ty2) = sameTy(ty1, ty2)
84 :     | same (Div ty1, Div ty2) = sameTy(ty1, ty2)
85 :     | same (Neg ty1, Neg ty2) = sameTy(ty1, ty2)
86 : jhr 180 | same (LT ty1, LT ty2) = sameTy(ty1, ty2)
87 :     | same (LTE ty1, LTE ty2) = sameTy(ty1, ty2)
88 :     | same (EQ ty1, EQ ty2) = sameTy(ty1, ty2)
89 :     | same (NEQ ty1, NEQ ty2) = sameTy(ty1, ty2)
90 :     | same (GT ty1, GT ty2) = sameTy(ty1, ty2)
91 :     | same (GTE ty1, GTE ty2) = sameTy(ty1, ty2)
92 : jhr 166 | same (Dot ty1, Dot ty2) = sameTy(ty1, ty2)
93 :     | same (Cross, Cross) = true
94 :     | same (Norm ty1, Norm ty2) = sameTy(ty1, ty2)
95 :     | same (Scale ty1, Scale ty2) = sameTy(ty1, ty2)
96 :     | same (CL, CL) = true
97 :     | same (PrincipleEvec, PrincipleEvec) = true
98 :     | same (Subscript ty1, Subscript ty2) = sameTy(ty1, ty2)
99 :     | same (Max, Max) = true
100 :     | same (Min, Min) = true
101 :     | same (Sin, Sin) = true
102 :     | same (Cos, Cos) = true
103 :     | same (Pow, Pow) = true
104 : jhr 180 | same (Not, Not) = true
105 : jhr 166 | same (IntToReal, IntToReal) = true
106 :     | same (TruncToInt, TruncToInt) = true
107 :     | same (RoundToInt, RoundToInt) = true
108 :     | same (CeilToInt, CeilToInt) = true
109 :     | same (FloorToInt, FloorToInt) = true
110 :     | same (LoadImage img1, LoadImage img2) = ImageInfo.same(img1, img2)
111 :     | same (Inside, Inside) = true
112 :     | same (Field fld1, Field fld2) = FieldDef.same(fld1, fld2)
113 :     | same (Probe, Probe) = true
114 :     | same (Transform img1, Transform img2) = ImageInfo.same(img1, img2)
115 :     | same _ = false
116 :    
117 :     fun hash (Add ty) = 0w11 + hashTy ty
118 :     | hash (Sub ty) = 0w13 + hashTy ty
119 :     | hash (Mul ty) = 0w17 + hashTy ty
120 :     | hash (Div ty) = 0w19 + hashTy ty
121 :     | hash (Neg ty) = 0w23 + hashTy ty
122 :     | hash (Dot ty) = 0w29 + hashTy ty
123 :     | hash Cross = 0w31
124 :     | hash (Norm ty) = 0w37 + hashTy ty
125 :     | hash (Scale ty) = 0w41 + hashTy ty
126 :     | hash CL = 0w43
127 :     | hash PrincipleEvec = 0w47
128 :     | hash (Subscript ty) = 0w53 + hashTy ty
129 :     | hash Max = 0w59
130 :     | hash Min = 0w61
131 :     | hash Sin = 0w67
132 :     | hash Cos = 0w71
133 :     | hash Pow = 0w73
134 :     | hash IntToReal = 0w79
135 :     | hash TruncToInt = 0w83
136 :     | hash RoundToInt = 0w89
137 :     | hash CeilToInt = 0w97
138 :     | hash FloorToInt = 0w101
139 :     | hash (LoadImage img) = 0w103 + ImageInfo.hash img
140 :     | hash Inside = 0w107
141 :     | hash (Field fld) = 0w109 + FieldDef.hash fld
142 :     | hash Probe = 0w113
143 :     | hash (Transform img) = 0w127 + ImageInfo.hash img
144 :    
145 :     val toString : rator -> string
146 :    
147 :     end
148 :    
149 :     structure HighIL = SSAFn(HighOps)

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