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

SCM Repository

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

Diff of /branches/vis12/src/compiler/mid-il/mid-il.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/src/compiler/mid-il/mid-il.sml revision 1640, Wed Nov 16 02:19:51 2011 UTC branches/vis12/src/compiler/mid-il/mid-il.sml revision 2027, Thu Oct 11 10:40:12 2012 UTC
# Line 33  Line 33 
33      val hashstring = HashString.hashString      val hashstring = HashString.hashString
34      fun stringToString s = String.concat["\"", s, "\""]      fun stringToString s = String.concat["\"", s, "\""]
35    
36      (* required helper functions for the input type *)
37        type input = ty Inputs.input
38        val sameinput = Inputs.same
39        val hashinput = Inputs.hash
40        val inputToString = Inputs.toString
41    
42      datatype rator      datatype rator
43        = Add of ty        = Add of ty
44        | Sub of ty        | Sub of ty
# Line 55  Line 61 
61        | MulVecMat of int * int        | MulVecMat of int * int
62        | MulMatVec of int * int        | MulMatVec of int * int
63        | MulMatMat of int * int * int        | MulMatMat of int * int * int
64          | MulVecTen3 of int * int * int
65          | MulTen3Vec of int * int * int
66          | ColonMul of ty * ty
67        | Cross        | Cross
68        | Norm of ty        | Norm of ty
69        | Normalize of int        | Normalize of int
# Line 70  Line 79 
79        | Select of ty * int        | Select of ty * int
80        | Index of ty * int        | Index of ty * int
81        | Subscript of ty        | Subscript of ty
82          | MkDynamic of ty * int
83          | Append of ty
84          | Prepend of ty
85          | Concat of ty
86          | Length of ty
87        | Ceiling of int        | Ceiling of int
88        | Floor of int        | Floor of int
89        | Round of int        | Round of int
# Line 81  Line 95 
95        | PosToImgSpace of ImageInfo.info        | PosToImgSpace of ImageInfo.info
96        | TensorToWorldSpace of ImageInfo.info * ty        | TensorToWorldSpace of ImageInfo.info * ty
97        | EvalKernel of int * Kernel.kernel * int        | EvalKernel of int * Kernel.kernel * int
       | LoadImage of ImageInfo.info  
98        | Inside of ImageInfo.info * int        | Inside of ImageInfo.info * int
99        | Input of ty * string * string        | LoadSeq of ty * string
100        | InputWithDefault of ty * string * string        | LoadImage of ty * string * ImageInfo.info
101          | Input of input
102        | Print of tys        | Print of tys
103    
104      fun resultArity (Add _) = 1      fun resultArity (Add _) = 1
# Line 108  Line 122 
122        | resultArity (MulVecMat _) = 1        | resultArity (MulVecMat _) = 1
123        | resultArity (MulMatVec _) = 1        | resultArity (MulMatVec _) = 1
124        | resultArity (MulMatMat _) = 1        | resultArity (MulMatMat _) = 1
125          | resultArity (MulVecTen3 _) = 1
126          | resultArity (MulTen3Vec _) = 1
127          | resultArity (ColonMul _) = 1
128        | resultArity Cross = 1        | resultArity Cross = 1
129        | resultArity (Norm _) = 1        | resultArity (Norm _) = 1
130        | resultArity (Normalize _) = 1        | resultArity (Normalize _) = 1
# Line 123  Line 140 
140        | resultArity (Select _) = 1        | resultArity (Select _) = 1
141        | resultArity (Index _) = 1        | resultArity (Index _) = 1
142        | resultArity (Subscript _) = 1        | resultArity (Subscript _) = 1
143          | resultArity (MkDynamic _) = 1
144          | resultArity (Append _) = 2
145          | resultArity (Prepend _) = 2
146          | resultArity (Concat _) = 2
147          | resultArity (Length _) = 1
148        | resultArity (Ceiling _) = 1        | resultArity (Ceiling _) = 1
149        | resultArity (Floor _) = 1        | resultArity (Floor _) = 1
150        | resultArity (Round _) = 1        | resultArity (Round _) = 1
# Line 134  Line 156 
156        | resultArity (PosToImgSpace _) = 1        | resultArity (PosToImgSpace _) = 1
157        | resultArity (TensorToWorldSpace _) = 1        | resultArity (TensorToWorldSpace _) = 1
158        | resultArity (EvalKernel _) = 1        | resultArity (EvalKernel _) = 1
       | resultArity (LoadImage _) = 1  
159        | resultArity (Inside _) = 1        | resultArity (Inside _) = 1
160        | resultArity (Input _) = 1        | resultArity (LoadSeq _) = 1
161        | resultArity (InputWithDefault _) = 1        | resultArity (LoadImage _) = 1
162          | resultArity (Input _) = 0
163        | resultArity (Print _) = 0        | resultArity (Print _) = 0
164    
165      fun arity (Add _) = 2      fun arity (Add _) = 2
# Line 161  Line 183 
183        | arity (MulVecMat _) = 2        | arity (MulVecMat _) = 2
184        | arity (MulMatVec _) = 2        | arity (MulMatVec _) = 2
185        | arity (MulMatMat _) = 2        | arity (MulMatMat _) = 2
186          | arity (MulVecTen3 _) = 2
187          | arity (MulTen3Vec _) = 2
188          | arity (ColonMul _) = 2
189        | arity Cross = 2        | arity Cross = 2
190        | arity (Norm _) = 1        | arity (Norm _) = 1
191        | arity (Normalize _) = 1        | arity (Normalize _) = 1
# Line 176  Line 201 
201        | arity (Select _) = 1        | arity (Select _) = 1
202        | arity (Index _) = 1        | arity (Index _) = 1
203        | arity (Subscript _) = 2        | arity (Subscript _) = 2
204          | arity (MkDynamic _) = 1
205          | arity (Append _) = 1
206          | arity (Prepend _) = 1
207          | arity (Concat _) = 1
208          | arity (Length _) = 1
209        | arity (Ceiling _) = 1        | arity (Ceiling _) = 1
210        | arity (Floor _) = 1        | arity (Floor _) = 1
211        | arity (Round _) = 1        | arity (Round _) = 1
# Line 187  Line 217 
217        | arity (PosToImgSpace _) = 2        | arity (PosToImgSpace _) = 2
218        | arity (TensorToWorldSpace _) = 2        | arity (TensorToWorldSpace _) = 2
219        | arity (EvalKernel _) = 1        | arity (EvalKernel _) = 1
       | arity (LoadImage _) = 1  
220        | arity (Inside _) = 2        | arity (Inside _) = 2
221          | arity (LoadSeq _) = 0
222          | arity (LoadImage _) = 0
223        | arity (Input _) = 0        | arity (Input _) = 0
       | arity (InputWithDefault _) = 1  
224        | arity (Print _) = ~1        | arity (Print _) = ~1
225    
226      fun same (Add(a0), Add(b0)) = samety(a0, b0)      fun same (Add(a0), Add(b0)) = samety(a0, b0)
# Line 214  Line 244 
244        | same (MulVecMat(a0,a1), MulVecMat(b0,b1)) = sameint(a0, b0) andalso sameint(a1, b1)        | same (MulVecMat(a0,a1), MulVecMat(b0,b1)) = sameint(a0, b0) andalso sameint(a1, b1)
245        | same (MulMatVec(a0,a1), MulMatVec(b0,b1)) = sameint(a0, b0) andalso sameint(a1, b1)        | same (MulMatVec(a0,a1), MulMatVec(b0,b1)) = sameint(a0, b0) andalso sameint(a1, b1)
246        | same (MulMatMat(a0,a1,a2), MulMatMat(b0,b1,b2)) = sameint(a0, b0) andalso sameint(a1, b1) andalso sameint(a2, b2)        | same (MulMatMat(a0,a1,a2), MulMatMat(b0,b1,b2)) = sameint(a0, b0) andalso sameint(a1, b1) andalso sameint(a2, b2)
247          | same (MulVecTen3(a0,a1,a2), MulVecTen3(b0,b1,b2)) = sameint(a0, b0) andalso sameint(a1, b1) andalso sameint(a2, b2)
248          | same (MulTen3Vec(a0,a1,a2), MulTen3Vec(b0,b1,b2)) = sameint(a0, b0) andalso sameint(a1, b1) andalso sameint(a2, b2)
249          | same (ColonMul(a0,a1), ColonMul(b0,b1)) = samety(a0, b0) andalso samety(a1, b1)
250        | same (Cross, Cross) = true        | same (Cross, Cross) = true
251        | same (Norm(a0), Norm(b0)) = samety(a0, b0)        | same (Norm(a0), Norm(b0)) = samety(a0, b0)
252        | same (Normalize(a0), Normalize(b0)) = sameint(a0, b0)        | same (Normalize(a0), Normalize(b0)) = sameint(a0, b0)
# Line 229  Line 262 
262        | same (Select(a0,a1), Select(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1)        | same (Select(a0,a1), Select(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1)
263        | same (Index(a0,a1), Index(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1)        | same (Index(a0,a1), Index(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1)
264        | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)        | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)
265          | same (MkDynamic(a0,a1), MkDynamic(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1)
266          | same (Append(a0), Append(b0)) = samety(a0, b0)
267          | same (Prepend(a0), Prepend(b0)) = samety(a0, b0)
268          | same (Concat(a0), Concat(b0)) = samety(a0, b0)
269          | same (Length(a0), Length(b0)) = samety(a0, b0)
270        | same (Ceiling(a0), Ceiling(b0)) = sameint(a0, b0)        | same (Ceiling(a0), Ceiling(b0)) = sameint(a0, b0)
271        | same (Floor(a0), Floor(b0)) = sameint(a0, b0)        | same (Floor(a0), Floor(b0)) = sameint(a0, b0)
272        | same (Round(a0), Round(b0)) = sameint(a0, b0)        | same (Round(a0), Round(b0)) = sameint(a0, b0)
# Line 240  Line 278 
278        | same (PosToImgSpace(a0), PosToImgSpace(b0)) = ImageInfo.same(a0, b0)        | same (PosToImgSpace(a0), PosToImgSpace(b0)) = ImageInfo.same(a0, b0)
279        | same (TensorToWorldSpace(a0,a1), TensorToWorldSpace(b0,b1)) = ImageInfo.same(a0, b0) andalso samety(a1, b1)        | same (TensorToWorldSpace(a0,a1), TensorToWorldSpace(b0,b1)) = ImageInfo.same(a0, b0) andalso samety(a1, b1)
280        | same (EvalKernel(a0,a1,a2), EvalKernel(b0,b1,b2)) = sameint(a0, b0) andalso Kernel.same(a1, b1) andalso sameint(a2, b2)        | same (EvalKernel(a0,a1,a2), EvalKernel(b0,b1,b2)) = sameint(a0, b0) andalso Kernel.same(a1, b1) andalso sameint(a2, b2)
       | same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0)  
281        | same (Inside(a0,a1), Inside(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1)        | same (Inside(a0,a1), Inside(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1)
282        | same (Input(a0,a1,a2), Input(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso samestring(a2, b2)        | same (LoadSeq(a0,a1), LoadSeq(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
283        | same (InputWithDefault(a0,a1,a2), InputWithDefault(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso samestring(a2, b2)        | same (LoadImage(a0,a1,a2), LoadImage(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso ImageInfo.same(a2, b2)
284          | same (Input(a0), Input(b0)) = sameinput(a0, b0)
285        | same (Print(a0), Print(b0)) = sametys(a0, b0)        | same (Print(a0), Print(b0)) = sametys(a0, b0)
286        | same _ = false        | same _ = false
287    
# Line 268  Line 306 
306        | hash (MulVecMat(a0,a1)) = 0w71 + hashint a0 + hashint a1        | hash (MulVecMat(a0,a1)) = 0w71 + hashint a0 + hashint a1
307        | hash (MulMatVec(a0,a1)) = 0w73 + hashint a0 + hashint a1        | hash (MulMatVec(a0,a1)) = 0w73 + hashint a0 + hashint a1
308        | hash (MulMatMat(a0,a1,a2)) = 0w79 + hashint a0 + hashint a1 + hashint a2        | hash (MulMatMat(a0,a1,a2)) = 0w79 + hashint a0 + hashint a1 + hashint a2
309        | hash Cross = 0w83        | hash (MulVecTen3(a0,a1,a2)) = 0w83 + hashint a0 + hashint a1 + hashint a2
310        | hash (Norm(a0)) = 0w89 + hashty a0        | hash (MulTen3Vec(a0,a1,a2)) = 0w89 + hashint a0 + hashint a1 + hashint a2
311        | hash (Normalize(a0)) = 0w97 + hashint a0        | hash (ColonMul(a0,a1)) = 0w97 + hashty a0 + hashty a1
312        | hash (Scale(a0)) = 0w101 + hashty a0        | hash Cross = 0w101
313        | hash (PrincipleEvec(a0)) = 0w103 + hashty a0        | hash (Norm(a0)) = 0w103 + hashty a0
314        | hash EigenVecs2x2 = 0w107        | hash (Normalize(a0)) = 0w107 + hashint a0
315        | hash EigenVecs3x3 = 0w109        | hash (Scale(a0)) = 0w109 + hashty a0
316        | hash EigenVals2x2 = 0w113        | hash (PrincipleEvec(a0)) = 0w113 + hashty a0
317        | hash EigenVals3x3 = 0w127        | hash EigenVecs2x2 = 0w127
318        | hash (Identity(a0)) = 0w131 + hashint a0        | hash EigenVecs3x3 = 0w131
319        | hash (Zero(a0)) = 0w137 + hashty a0        | hash EigenVals2x2 = 0w137
320        | hash (Trace(a0)) = 0w139 + hashint a0        | hash EigenVals3x3 = 0w139
321        | hash (Select(a0,a1)) = 0w149 + hashty a0 + hashint a1        | hash (Identity(a0)) = 0w149 + hashint a0
322        | hash (Index(a0,a1)) = 0w151 + hashty a0 + hashint a1        | hash (Zero(a0)) = 0w151 + hashty a0
323        | hash (Subscript(a0)) = 0w157 + hashty a0        | hash (Trace(a0)) = 0w157 + hashint a0
324        | hash (Ceiling(a0)) = 0w163 + hashint a0        | hash (Select(a0,a1)) = 0w163 + hashty a0 + hashint a1
325        | hash (Floor(a0)) = 0w167 + hashint a0        | hash (Index(a0,a1)) = 0w167 + hashty a0 + hashint a1
326        | hash (Round(a0)) = 0w173 + hashint a0        | hash (Subscript(a0)) = 0w173 + hashty a0
327        | hash (Trunc(a0)) = 0w179 + hashint a0        | hash (MkDynamic(a0,a1)) = 0w179 + hashty a0 + hashint a1
328        | hash IntToReal = 0w181        | hash (Append(a0)) = 0w181 + hashty a0
329        | hash (RealToInt(a0)) = 0w191 + hashint a0        | hash (Prepend(a0)) = 0w191 + hashty a0
330        | hash (VoxelAddress(a0,a1)) = 0w193 + ImageInfo.hash a0 + hashint a1        | hash (Concat(a0)) = 0w193 + hashty a0
331        | hash (LoadVoxels(a0,a1)) = 0w197 + ImageInfo.hash a0 + hashint a1        | hash (Length(a0)) = 0w197 + hashty a0
332        | hash (PosToImgSpace(a0)) = 0w199 + ImageInfo.hash a0        | hash (Ceiling(a0)) = 0w199 + hashint a0
333        | hash (TensorToWorldSpace(a0,a1)) = 0w211 + ImageInfo.hash a0 + hashty a1        | hash (Floor(a0)) = 0w211 + hashint a0
334        | hash (EvalKernel(a0,a1,a2)) = 0w223 + hashint a0 + Kernel.hash a1 + hashint a2        | hash (Round(a0)) = 0w223 + hashint a0
335        | hash (LoadImage(a0)) = 0w227 + ImageInfo.hash a0        | hash (Trunc(a0)) = 0w227 + hashint a0
336        | hash (Inside(a0,a1)) = 0w229 + ImageInfo.hash a0 + hashint a1        | hash IntToReal = 0w229
337        | hash (Input(a0,a1,a2)) = 0w233 + hashty a0 + hashstring a1 + hashstring a2        | hash (RealToInt(a0)) = 0w233 + hashint a0
338        | hash (InputWithDefault(a0,a1,a2)) = 0w239 + hashty a0 + hashstring a1 + hashstring a2        | hash (VoxelAddress(a0,a1)) = 0w239 + ImageInfo.hash a0 + hashint a1
339        | hash (Print(a0)) = 0w241 + hashtys a0        | hash (LoadVoxels(a0,a1)) = 0w241 + ImageInfo.hash a0 + hashint a1
340          | hash (PosToImgSpace(a0)) = 0w251 + ImageInfo.hash a0
341          | hash (TensorToWorldSpace(a0,a1)) = 0w257 + ImageInfo.hash a0 + hashty a1
342          | hash (EvalKernel(a0,a1,a2)) = 0w263 + hashint a0 + Kernel.hash a1 + hashint a2
343          | hash (Inside(a0,a1)) = 0w269 + ImageInfo.hash a0 + hashint a1
344          | hash (LoadSeq(a0,a1)) = 0w271 + hashty a0 + hashstring a1
345          | hash (LoadImage(a0,a1,a2)) = 0w277 + hashty a0 + hashstring a1 + ImageInfo.hash a2
346          | hash (Input(a0)) = 0w281 + hashinput a0
347          | hash (Print(a0)) = 0w283 + hashtys a0
348    
349      fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]      fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]
350        | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]        | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]
# Line 321  Line 367 
367        | toString (MulVecMat(a0,a1)) = concat["MulVecMat<", intToString a0, ",", intToString a1, ">"]        | toString (MulVecMat(a0,a1)) = concat["MulVecMat<", intToString a0, ",", intToString a1, ">"]
368        | toString (MulMatVec(a0,a1)) = concat["MulMatVec<", intToString a0, ",", intToString a1, ">"]        | toString (MulMatVec(a0,a1)) = concat["MulMatVec<", intToString a0, ",", intToString a1, ">"]
369        | toString (MulMatMat(a0,a1,a2)) = concat["MulMatMat<", intToString a0, ",", intToString a1, ",", intToString a2, ">"]        | toString (MulMatMat(a0,a1,a2)) = concat["MulMatMat<", intToString a0, ",", intToString a1, ",", intToString a2, ">"]
370          | toString (MulVecTen3(a0,a1,a2)) = concat["MulVecTen3<", intToString a0, ",", intToString a1, ",", intToString a2, ">"]
371          | toString (MulTen3Vec(a0,a1,a2)) = concat["MulTen3Vec<", intToString a0, ",", intToString a1, ",", intToString a2, ">"]
372          | toString (ColonMul(a0,a1)) = concat["ColonMul<", tyToString a0, ",", tyToString a1, ">"]
373        | toString Cross = "Cross"        | toString Cross = "Cross"
374        | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]        | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]
375        | toString (Normalize(a0)) = concat["Normalize<", intToString a0, ">"]        | toString (Normalize(a0)) = concat["Normalize<", intToString a0, ">"]
# Line 336  Line 385 
385        | toString (Select(a0,a1)) = concat["Select<", tyToString a0, ",", intToString a1, ">"]        | toString (Select(a0,a1)) = concat["Select<", tyToString a0, ",", intToString a1, ">"]
386        | toString (Index(a0,a1)) = concat["Index<", tyToString a0, ",", intToString a1, ">"]        | toString (Index(a0,a1)) = concat["Index<", tyToString a0, ",", intToString a1, ">"]
387        | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]        | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]
388          | toString (MkDynamic(a0,a1)) = concat["MkDynamic<", tyToString a0, ",", intToString a1, ">"]
389          | toString (Append(a0)) = concat["Append<", tyToString a0, ">"]
390          | toString (Prepend(a0)) = concat["Prepend<", tyToString a0, ">"]
391          | toString (Concat(a0)) = concat["Concat<", tyToString a0, ">"]
392          | toString (Length(a0)) = concat["Length<", tyToString a0, ">"]
393        | toString (Ceiling(a0)) = concat["Ceiling<", intToString a0, ">"]        | toString (Ceiling(a0)) = concat["Ceiling<", intToString a0, ">"]
394        | toString (Floor(a0)) = concat["Floor<", intToString a0, ">"]        | toString (Floor(a0)) = concat["Floor<", intToString a0, ">"]
395        | toString (Round(a0)) = concat["Round<", intToString a0, ">"]        | toString (Round(a0)) = concat["Round<", intToString a0, ">"]
# Line 347  Line 401 
401        | toString (PosToImgSpace(a0)) = concat["PosToImgSpace<", ImageInfo.toString a0, ">"]        | toString (PosToImgSpace(a0)) = concat["PosToImgSpace<", ImageInfo.toString a0, ">"]
402        | toString (TensorToWorldSpace(a0,a1)) = concat["TensorToWorldSpace<", ImageInfo.toString a0, ",", tyToString a1, ">"]        | toString (TensorToWorldSpace(a0,a1)) = concat["TensorToWorldSpace<", ImageInfo.toString a0, ",", tyToString a1, ">"]
403        | toString (EvalKernel(a0,a1,a2)) = concat["EvalKernel<", intToString a0, ",", Kernel.toString a1, ",", intToString a2, ">"]        | toString (EvalKernel(a0,a1,a2)) = concat["EvalKernel<", intToString a0, ",", Kernel.toString a1, ",", intToString a2, ">"]
       | toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"]  
404        | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"]        | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"]
405        | toString (Input(a0,a1,a2)) = concat["Input<", tyToString a0, ",", stringToString a1, ",", stringToString a2, ">"]        | toString (LoadSeq(a0,a1)) = concat["LoadSeq<", tyToString a0, ",", stringToString a1, ">"]
406        | toString (InputWithDefault(a0,a1,a2)) = concat["InputWithDefault<", tyToString a0, ",", stringToString a1, ",", stringToString a2, ">"]        | toString (LoadImage(a0,a1,a2)) = concat["LoadImage<", tyToString a0, ",", stringToString a1, ",", ImageInfo.toString a2, ">"]
407          | toString (Input(a0)) = concat["Input<", inputToString a0, ">"]
408        | toString (Print(a0)) = concat["Print<", tysToString a0, ">"]        | toString (Print(a0)) = concat["Print<", tysToString a0, ">"]
409    
410    end    end

Legend:
Removed from v.1640  
changed lines
  Added in v.2027

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