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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1116 - (view) (download)

1 : jhr 166 (* high-il.sml
2 :     *
3 : jhr 435 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 : jhr 166 * All rights reserved.
5 :     *
6 :     * High-level version of the Diderot IL.
7 : jhr 186 *
8 :     * Note: this file is generated from gen/high-il.spec and gen/high-il.in.
9 : jhr 166 *)
10 :    
11 :     structure HighOps =
12 :     struct
13 :    
14 : jhr 392 type ty = HighILTypes.ty
15 : jhr 166
16 : jhr 392 val samety = HighILTypes.same
17 :     val hashty = HighILTypes.hash
18 :     val tyToString = HighILTypes.toString
19 : jhr 166
20 : jhr 1116 (* required helper functions for the int type *)
21 :     fun sameint (i1 : int, i2) = (i1 = i2)
22 :     fun hashint i = Word.fromInt i
23 :     fun intToString i = Int.toString i
24 :    
25 : jhr 336 (* required helper functions for the string type *)
26 : jhr 226 fun samestring (s1 : string, s2) = (s1 = s2)
27 :     val hashstring = HashString.hashString
28 :     fun stringToString s = String.concat["\"", s, "\""]
29 :    
30 : jhr 407 (* required helper functions for the mask type *)
31 : jhr 400 type mask = bool list
32 :     val samemask : (mask * mask -> bool) = (op =)
33 :     fun hashmask m =
34 :     List.foldl (fn (false, w) => w+w | (true, w) => w+w+0w1)
35 :     (Word.fromInt(List.length m)) m
36 :     fun maskToString m =
37 :     String.concat(List.map (fn true => "_" | false => ":") m)
38 :    
39 : jhr 166 datatype rator
40 : jhr 186 = Add of ty
41 :     | Sub of ty
42 :     | Mul of ty
43 :     | Div of ty
44 : jhr 166 | Neg of ty
45 : jhr 1116 | Abs of ty
46 : jhr 186 | LT of ty
47 :     | LTE of ty
48 :     | EQ of ty
49 :     | NEQ of ty
50 :     | GT of ty
51 :     | GTE of ty
52 : jhr 1116 | Power
53 :     | Not
54 : jhr 400 | Max
55 :     | Min
56 : jhr 1116 | Lerp of ty
57 : jhr 186 | Dot of ty
58 : jhr 1116 | MulVecMat of ty
59 :     | MulMatVec of ty
60 :     | MulMatMat of ty * ty
61 : jhr 186 | Cross
62 : jhr 1116 | Outer of ty
63 : jhr 186 | Norm of ty
64 : jhr 1116 | Normalize of ty
65 : jhr 186 | Scale of ty
66 :     | CL
67 :     | PrincipleEvec of ty
68 : jhr 1116 | Identity of int
69 :     | Zero of ty
70 :     | Trace of ty
71 : jhr 400 | Slice of ty * mask
72 : jhr 166 | Subscript of ty
73 :     | IntToReal
74 :     | TruncToInt
75 :     | RoundToInt
76 :     | CeilToInt
77 :     | FloorToInt
78 : jhr 1116 | Kernel of Kernel.kernel * int
79 : jhr 186 | LoadImage of ImageInfo.info
80 : jhr 1116 | Inside of int
81 :     | Field of int
82 :     | Probe of ty * ty
83 : jhr 195 | AddField
84 : jhr 1116 | SubField
85 : jhr 195 | ScaleField
86 :     | NegField
87 :     | DiffField
88 : jhr 407 | Input of ty * string
89 :     | InputWithDefault of ty * string
90 : jhr 166
91 :     fun arity (Add _) = 2
92 :     | arity (Sub _) = 2
93 :     | arity (Mul _) = 2
94 :     | arity (Div _) = 2
95 :     | arity (Neg _) = 1
96 : jhr 1116 | arity (Abs _) = 1
97 : jhr 180 | arity (LT _) = 2
98 :     | arity (LTE _) = 2
99 :     | arity (EQ _) = 2
100 :     | arity (NEQ _) = 2
101 :     | arity (GT _) = 2
102 :     | arity (GTE _) = 2
103 : jhr 1116 | arity Power = 2
104 :     | arity Not = 1
105 : jhr 400 | arity Max = 2
106 :     | arity Min = 2
107 : jhr 1116 | arity (Lerp _) = 3
108 : jhr 166 | arity (Dot _) = 2
109 : jhr 1116 | arity (MulVecMat _) = 2
110 :     | arity (MulMatVec _) = 2
111 :     | arity (MulMatMat _) = 2
112 : jhr 166 | arity Cross = 2
113 : jhr 1116 | arity (Outer _) = 2
114 : jhr 166 | arity (Norm _) = 1
115 : jhr 1116 | arity (Normalize _) = 1
116 : jhr 166 | arity (Scale _) = 2
117 : jhr 186 | arity CL = 1
118 :     | arity (PrincipleEvec _) = 2
119 : jhr 1116 | arity (Identity _) = 0
120 :     | arity (Zero _) = 0
121 :     | arity (Trace _) = 1
122 : jhr 400 | arity (Slice _) = 1
123 :     | arity (Subscript _) = ~1
124 : jhr 166 | arity IntToReal = 1
125 :     | arity TruncToInt = 1
126 :     | arity RoundToInt = 1
127 :     | arity CeilToInt = 1
128 :     | arity FloorToInt = 1
129 : jhr 195 | arity (Kernel _) = 0
130 : jhr 1116 | arity (LoadImage _) = 1
131 : jhr 407 | arity (Inside _) = 2
132 : jhr 1116 | arity (Field _) = 2
133 :     | arity (Probe _) = 2
134 : jhr 195 | arity AddField = 2
135 : jhr 1116 | arity SubField = 2
136 : jhr 195 | arity ScaleField = 2
137 :     | arity NegField = 1
138 :     | arity DiffField = 1
139 : jhr 226 | arity (Input _) = 0
140 :     | arity (InputWithDefault _) = 1
141 : jhr 166
142 : jhr 282 fun same (Add(a0), Add(b0)) = samety(a0, b0)
143 :     | same (Sub(a0), Sub(b0)) = samety(a0, b0)
144 :     | same (Mul(a0), Mul(b0)) = samety(a0, b0)
145 :     | same (Div(a0), Div(b0)) = samety(a0, b0)
146 :     | same (Neg(a0), Neg(b0)) = samety(a0, b0)
147 : jhr 1116 | same (Abs(a0), Abs(b0)) = samety(a0, b0)
148 : jhr 282 | same (LT(a0), LT(b0)) = samety(a0, b0)
149 :     | same (LTE(a0), LTE(b0)) = samety(a0, b0)
150 :     | same (EQ(a0), EQ(b0)) = samety(a0, b0)
151 :     | same (NEQ(a0), NEQ(b0)) = samety(a0, b0)
152 :     | same (GT(a0), GT(b0)) = samety(a0, b0)
153 :     | same (GTE(a0), GTE(b0)) = samety(a0, b0)
154 : jhr 1116 | same (Power, Power) = true
155 :     | same (Not, Not) = true
156 : jhr 400 | same (Max, Max) = true
157 :     | same (Min, Min) = true
158 : jhr 1116 | same (Lerp(a0), Lerp(b0)) = samety(a0, b0)
159 : jhr 282 | same (Dot(a0), Dot(b0)) = samety(a0, b0)
160 : jhr 1116 | same (MulVecMat(a0), MulVecMat(b0)) = samety(a0, b0)
161 :     | same (MulMatVec(a0), MulMatVec(b0)) = samety(a0, b0)
162 :     | same (MulMatMat(a0,a1), MulMatMat(b0,b1)) = samety(a0, b0) andalso samety(a1, b1)
163 : jhr 166 | same (Cross, Cross) = true
164 : jhr 1116 | same (Outer(a0), Outer(b0)) = samety(a0, b0)
165 : jhr 282 | same (Norm(a0), Norm(b0)) = samety(a0, b0)
166 : jhr 1116 | same (Normalize(a0), Normalize(b0)) = samety(a0, b0)
167 : jhr 282 | same (Scale(a0), Scale(b0)) = samety(a0, b0)
168 : jhr 166 | same (CL, CL) = true
169 : jhr 282 | same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0)
170 : jhr 1116 | same (Identity(a0), Identity(b0)) = sameint(a0, b0)
171 :     | same (Zero(a0), Zero(b0)) = samety(a0, b0)
172 :     | same (Trace(a0), Trace(b0)) = samety(a0, b0)
173 : jhr 400 | same (Slice(a0,a1), Slice(b0,b1)) = samety(a0, b0) andalso samemask(a1, b1)
174 : jhr 282 | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)
175 : jhr 166 | same (IntToReal, IntToReal) = true
176 :     | same (TruncToInt, TruncToInt) = true
177 :     | same (RoundToInt, RoundToInt) = true
178 :     | same (CeilToInt, CeilToInt) = true
179 :     | same (FloorToInt, FloorToInt) = true
180 : jhr 1116 | same (Kernel(a0,a1), Kernel(b0,b1)) = Kernel.same(a0, b0) andalso sameint(a1, b1)
181 : jhr 282 | same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0)
182 : jhr 1116 | same (Inside(a0), Inside(b0)) = sameint(a0, b0)
183 :     | same (Field(a0), Field(b0)) = sameint(a0, b0)
184 :     | same (Probe(a0,a1), Probe(b0,b1)) = samety(a0, b0) andalso samety(a1, b1)
185 : jhr 195 | same (AddField, AddField) = true
186 : jhr 1116 | same (SubField, SubField) = true
187 : jhr 195 | same (ScaleField, ScaleField) = true
188 :     | same (NegField, NegField) = true
189 :     | same (DiffField, DiffField) = true
190 : jhr 407 | same (Input(a0,a1), Input(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
191 :     | same (InputWithDefault(a0,a1), InputWithDefault(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
192 : jhr 166 | same _ = false
193 :    
194 : jhr 282 fun hash (Add(a0)) = 0w3 + hashty a0
195 :     | hash (Sub(a0)) = 0w5 + hashty a0
196 :     | hash (Mul(a0)) = 0w7 + hashty a0
197 :     | hash (Div(a0)) = 0w11 + hashty a0
198 :     | hash (Neg(a0)) = 0w13 + hashty a0
199 : jhr 1116 | hash (Abs(a0)) = 0w17 + hashty a0
200 :     | hash (LT(a0)) = 0w19 + hashty a0
201 :     | hash (LTE(a0)) = 0w23 + hashty a0
202 :     | hash (EQ(a0)) = 0w29 + hashty a0
203 :     | hash (NEQ(a0)) = 0w31 + hashty a0
204 :     | hash (GT(a0)) = 0w37 + hashty a0
205 :     | hash (GTE(a0)) = 0w41 + hashty a0
206 :     | hash Power = 0w43
207 :     | hash Not = 0w47
208 :     | hash Max = 0w53
209 :     | hash Min = 0w59
210 :     | hash (Lerp(a0)) = 0w61 + hashty a0
211 : jhr 400 | hash (Dot(a0)) = 0w67 + hashty a0
212 : jhr 1116 | hash (MulVecMat(a0)) = 0w71 + hashty a0
213 :     | hash (MulMatVec(a0)) = 0w73 + hashty a0
214 :     | hash (MulMatMat(a0,a1)) = 0w79 + hashty a0 + hashty a1
215 :     | hash Cross = 0w83
216 :     | hash (Outer(a0)) = 0w89 + hashty a0
217 :     | hash (Norm(a0)) = 0w97 + hashty a0
218 :     | hash (Normalize(a0)) = 0w101 + hashty a0
219 :     | hash (Scale(a0)) = 0w103 + hashty a0
220 :     | hash CL = 0w107
221 :     | hash (PrincipleEvec(a0)) = 0w109 + hashty a0
222 :     | hash (Identity(a0)) = 0w113 + hashint a0
223 :     | hash (Zero(a0)) = 0w127 + hashty a0
224 :     | hash (Trace(a0)) = 0w131 + hashty a0
225 :     | hash (Slice(a0,a1)) = 0w137 + hashty a0 + hashmask a1
226 :     | hash (Subscript(a0)) = 0w139 + hashty a0
227 :     | hash IntToReal = 0w149
228 :     | hash TruncToInt = 0w151
229 :     | hash RoundToInt = 0w157
230 :     | hash CeilToInt = 0w163
231 :     | hash FloorToInt = 0w167
232 :     | hash (Kernel(a0,a1)) = 0w173 + Kernel.hash a0 + hashint a1
233 :     | hash (LoadImage(a0)) = 0w179 + ImageInfo.hash a0
234 :     | hash (Inside(a0)) = 0w181 + hashint a0
235 :     | hash (Field(a0)) = 0w191 + hashint a0
236 :     | hash (Probe(a0,a1)) = 0w193 + hashty a0 + hashty a1
237 :     | hash AddField = 0w197
238 :     | hash SubField = 0w199
239 :     | hash ScaleField = 0w211
240 :     | hash NegField = 0w223
241 :     | hash DiffField = 0w227
242 :     | hash (Input(a0,a1)) = 0w229 + hashty a0 + hashstring a1
243 :     | hash (InputWithDefault(a0,a1)) = 0w233 + hashty a0 + hashstring a1
244 : jhr 166
245 : jhr 282 fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]
246 :     | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]
247 :     | toString (Mul(a0)) = concat["Mul<", tyToString a0, ">"]
248 :     | toString (Div(a0)) = concat["Div<", tyToString a0, ">"]
249 :     | toString (Neg(a0)) = concat["Neg<", tyToString a0, ">"]
250 : jhr 1116 | toString (Abs(a0)) = concat["Abs<", tyToString a0, ">"]
251 : jhr 282 | toString (LT(a0)) = concat["LT<", tyToString a0, ">"]
252 :     | toString (LTE(a0)) = concat["LTE<", tyToString a0, ">"]
253 :     | toString (EQ(a0)) = concat["EQ<", tyToString a0, ">"]
254 :     | toString (NEQ(a0)) = concat["NEQ<", tyToString a0, ">"]
255 :     | toString (GT(a0)) = concat["GT<", tyToString a0, ">"]
256 :     | toString (GTE(a0)) = concat["GTE<", tyToString a0, ">"]
257 : jhr 1116 | toString Power = "Power"
258 :     | toString Not = "Not"
259 : jhr 400 | toString Max = "Max"
260 :     | toString Min = "Min"
261 : jhr 1116 | toString (Lerp(a0)) = concat["Lerp<", tyToString a0, ">"]
262 : jhr 282 | toString (Dot(a0)) = concat["Dot<", tyToString a0, ">"]
263 : jhr 1116 | toString (MulVecMat(a0)) = concat["MulVecMat<", tyToString a0, ">"]
264 :     | toString (MulMatVec(a0)) = concat["MulMatVec<", tyToString a0, ">"]
265 :     | toString (MulMatMat(a0,a1)) = concat["MulMatMat<", tyToString a0, ",", tyToString a1, ">"]
266 : jhr 186 | toString Cross = "Cross"
267 : jhr 1116 | toString (Outer(a0)) = concat["Outer<", tyToString a0, ">"]
268 : jhr 282 | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]
269 : jhr 1116 | toString (Normalize(a0)) = concat["Normalize<", tyToString a0, ">"]
270 : jhr 282 | toString (Scale(a0)) = concat["Scale<", tyToString a0, ">"]
271 : jhr 186 | toString CL = "CL"
272 : jhr 282 | toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"]
273 : jhr 1116 | toString (Identity(a0)) = concat["Identity<", intToString a0, ">"]
274 :     | toString (Zero(a0)) = concat["Zero<", tyToString a0, ">"]
275 :     | toString (Trace(a0)) = concat["Trace<", tyToString a0, ">"]
276 : jhr 400 | toString (Slice(a0,a1)) = concat["Slice<", tyToString a0, ",", maskToString a1, ">"]
277 : jhr 282 | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]
278 : jhr 186 | toString IntToReal = "IntToReal"
279 :     | toString TruncToInt = "TruncToInt"
280 :     | toString RoundToInt = "RoundToInt"
281 :     | toString CeilToInt = "CeilToInt"
282 :     | toString FloorToInt = "FloorToInt"
283 : jhr 1116 | toString (Kernel(a0,a1)) = concat["Kernel<", Kernel.toString a0, ",", intToString a1, ">"]
284 : jhr 282 | toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"]
285 : jhr 1116 | toString (Inside(a0)) = concat["Inside<", intToString a0, ">"]
286 :     | toString (Field(a0)) = concat["Field<", intToString a0, ">"]
287 :     | toString (Probe(a0,a1)) = concat["Probe<", tyToString a0, ",", tyToString a1, ">"]
288 : jhr 195 | toString AddField = "AddField"
289 : jhr 1116 | toString SubField = "SubField"
290 : jhr 195 | toString ScaleField = "ScaleField"
291 :     | toString NegField = "NegField"
292 :     | toString DiffField = "DiffField"
293 : jhr 407 | toString (Input(a0,a1)) = concat["Input<", tyToString a0, ",", stringToString a1, ">"]
294 :     | toString (InputWithDefault(a0,a1)) = concat["InputWithDefault<", tyToString a0, ",", stringToString a1, ">"]
295 : jhr 166
296 :     end
297 :    
298 : jhr 392 structure HighIL = SSAFn(
299 :     structure Ty = HighILTypes
300 :     structure Op = HighOps)
301 : jhr 1116
302 :     structure HighILCensus = CensusFn(HighIL)
303 :    

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