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 2011, Sun Oct 7 21:14:31 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        | Input of input
       | InputWithDefault of ty * string * string  
100        | Print of tys        | Print of tys
101    
102      fun resultArity (Add _) = 1      fun resultArity (Add _) = 1
# Line 108  Line 120 
120        | resultArity (MulVecMat _) = 1        | resultArity (MulVecMat _) = 1
121        | resultArity (MulMatVec _) = 1        | resultArity (MulMatVec _) = 1
122        | resultArity (MulMatMat _) = 1        | resultArity (MulMatMat _) = 1
123          | resultArity (MulVecTen3 _) = 1
124          | resultArity (MulTen3Vec _) = 1
125          | resultArity (ColonMul _) = 1
126        | resultArity Cross = 1        | resultArity Cross = 1
127        | resultArity (Norm _) = 1        | resultArity (Norm _) = 1
128        | resultArity (Normalize _) = 1        | resultArity (Normalize _) = 1
# Line 123  Line 138 
138        | resultArity (Select _) = 1        | resultArity (Select _) = 1
139        | resultArity (Index _) = 1        | resultArity (Index _) = 1
140        | resultArity (Subscript _) = 1        | resultArity (Subscript _) = 1
141          | resultArity (MkDynamic _) = 1
142          | resultArity (Append _) = 2
143          | resultArity (Prepend _) = 2
144          | resultArity (Concat _) = 2
145          | resultArity (Length _) = 1
146        | resultArity (Ceiling _) = 1        | resultArity (Ceiling _) = 1
147        | resultArity (Floor _) = 1        | resultArity (Floor _) = 1
148        | resultArity (Round _) = 1        | resultArity (Round _) = 1
# Line 134  Line 154 
154        | resultArity (PosToImgSpace _) = 1        | resultArity (PosToImgSpace _) = 1
155        | resultArity (TensorToWorldSpace _) = 1        | resultArity (TensorToWorldSpace _) = 1
156        | resultArity (EvalKernel _) = 1        | resultArity (EvalKernel _) = 1
       | resultArity (LoadImage _) = 1  
157        | resultArity (Inside _) = 1        | resultArity (Inside _) = 1
158        | resultArity (Input _) = 1        | resultArity (Input _) = 0
       | resultArity (InputWithDefault _) = 1  
159        | resultArity (Print _) = 0        | resultArity (Print _) = 0
160    
161      fun arity (Add _) = 2      fun arity (Add _) = 2
# Line 161  Line 179 
179        | arity (MulVecMat _) = 2        | arity (MulVecMat _) = 2
180        | arity (MulMatVec _) = 2        | arity (MulMatVec _) = 2
181        | arity (MulMatMat _) = 2        | arity (MulMatMat _) = 2
182          | arity (MulVecTen3 _) = 2
183          | arity (MulTen3Vec _) = 2
184          | arity (ColonMul _) = 2
185        | arity Cross = 2        | arity Cross = 2
186        | arity (Norm _) = 1        | arity (Norm _) = 1
187        | arity (Normalize _) = 1        | arity (Normalize _) = 1
# Line 176  Line 197 
197        | arity (Select _) = 1        | arity (Select _) = 1
198        | arity (Index _) = 1        | arity (Index _) = 1
199        | arity (Subscript _) = 2        | arity (Subscript _) = 2
200          | arity (MkDynamic _) = 1
201          | arity (Append _) = 1
202          | arity (Prepend _) = 1
203          | arity (Concat _) = 1
204          | arity (Length _) = 1
205        | arity (Ceiling _) = 1        | arity (Ceiling _) = 1
206        | arity (Floor _) = 1        | arity (Floor _) = 1
207        | arity (Round _) = 1        | arity (Round _) = 1
# Line 187  Line 213 
213        | arity (PosToImgSpace _) = 2        | arity (PosToImgSpace _) = 2
214        | arity (TensorToWorldSpace _) = 2        | arity (TensorToWorldSpace _) = 2
215        | arity (EvalKernel _) = 1        | arity (EvalKernel _) = 1
       | arity (LoadImage _) = 1  
216        | arity (Inside _) = 2        | arity (Inside _) = 2
217        | arity (Input _) = 0        | arity (Input _) = 0
       | arity (InputWithDefault _) = 1  
218        | arity (Print _) = ~1        | arity (Print _) = ~1
219    
220      fun same (Add(a0), Add(b0)) = samety(a0, b0)      fun same (Add(a0), Add(b0)) = samety(a0, b0)
# Line 214  Line 238 
238        | 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)
239        | 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)
240        | 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)
241          | same (MulVecTen3(a0,a1,a2), MulVecTen3(b0,b1,b2)) = sameint(a0, b0) andalso sameint(a1, b1) andalso sameint(a2, b2)
242          | same (MulTen3Vec(a0,a1,a2), MulTen3Vec(b0,b1,b2)) = sameint(a0, b0) andalso sameint(a1, b1) andalso sameint(a2, b2)
243          | same (ColonMul(a0,a1), ColonMul(b0,b1)) = samety(a0, b0) andalso samety(a1, b1)
244        | same (Cross, Cross) = true        | same (Cross, Cross) = true
245        | same (Norm(a0), Norm(b0)) = samety(a0, b0)        | same (Norm(a0), Norm(b0)) = samety(a0, b0)
246        | same (Normalize(a0), Normalize(b0)) = sameint(a0, b0)        | same (Normalize(a0), Normalize(b0)) = sameint(a0, b0)
# Line 229  Line 256 
256        | 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)
257        | 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)
258        | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)        | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)
259          | same (MkDynamic(a0,a1), MkDynamic(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1)
260          | same (Append(a0), Append(b0)) = samety(a0, b0)
261          | same (Prepend(a0), Prepend(b0)) = samety(a0, b0)
262          | same (Concat(a0), Concat(b0)) = samety(a0, b0)
263          | same (Length(a0), Length(b0)) = samety(a0, b0)
264        | same (Ceiling(a0), Ceiling(b0)) = sameint(a0, b0)        | same (Ceiling(a0), Ceiling(b0)) = sameint(a0, b0)
265        | same (Floor(a0), Floor(b0)) = sameint(a0, b0)        | same (Floor(a0), Floor(b0)) = sameint(a0, b0)
266        | same (Round(a0), Round(b0)) = sameint(a0, b0)        | same (Round(a0), Round(b0)) = sameint(a0, b0)
# Line 240  Line 272 
272        | same (PosToImgSpace(a0), PosToImgSpace(b0)) = ImageInfo.same(a0, b0)        | same (PosToImgSpace(a0), PosToImgSpace(b0)) = ImageInfo.same(a0, b0)
273        | 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)
274        | 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)  
275        | 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)
276        | same (Input(a0,a1,a2), Input(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso samestring(a2, b2)        | same (Input(a0), Input(b0)) = sameinput(a0, b0)
       | same (InputWithDefault(a0,a1,a2), InputWithDefault(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso samestring(a2, b2)  
277        | same (Print(a0), Print(b0)) = sametys(a0, b0)        | same (Print(a0), Print(b0)) = sametys(a0, b0)
278        | same _ = false        | same _ = false
279    
# Line 268  Line 298 
298        | hash (MulVecMat(a0,a1)) = 0w71 + hashint a0 + hashint a1        | hash (MulVecMat(a0,a1)) = 0w71 + hashint a0 + hashint a1
299        | hash (MulMatVec(a0,a1)) = 0w73 + hashint a0 + hashint a1        | hash (MulMatVec(a0,a1)) = 0w73 + hashint a0 + hashint a1
300        | hash (MulMatMat(a0,a1,a2)) = 0w79 + hashint a0 + hashint a1 + hashint a2        | hash (MulMatMat(a0,a1,a2)) = 0w79 + hashint a0 + hashint a1 + hashint a2
301        | hash Cross = 0w83        | hash (MulVecTen3(a0,a1,a2)) = 0w83 + hashint a0 + hashint a1 + hashint a2
302        | hash (Norm(a0)) = 0w89 + hashty a0        | hash (MulTen3Vec(a0,a1,a2)) = 0w89 + hashint a0 + hashint a1 + hashint a2
303        | hash (Normalize(a0)) = 0w97 + hashint a0        | hash (ColonMul(a0,a1)) = 0w97 + hashty a0 + hashty a1
304        | hash (Scale(a0)) = 0w101 + hashty a0        | hash Cross = 0w101
305        | hash (PrincipleEvec(a0)) = 0w103 + hashty a0        | hash (Norm(a0)) = 0w103 + hashty a0
306        | hash EigenVecs2x2 = 0w107        | hash (Normalize(a0)) = 0w107 + hashint a0
307        | hash EigenVecs3x3 = 0w109        | hash (Scale(a0)) = 0w109 + hashty a0
308        | hash EigenVals2x2 = 0w113        | hash (PrincipleEvec(a0)) = 0w113 + hashty a0
309        | hash EigenVals3x3 = 0w127        | hash EigenVecs2x2 = 0w127
310        | hash (Identity(a0)) = 0w131 + hashint a0        | hash EigenVecs3x3 = 0w131
311        | hash (Zero(a0)) = 0w137 + hashty a0        | hash EigenVals2x2 = 0w137
312        | hash (Trace(a0)) = 0w139 + hashint a0        | hash EigenVals3x3 = 0w139
313        | hash (Select(a0,a1)) = 0w149 + hashty a0 + hashint a1        | hash (Identity(a0)) = 0w149 + hashint a0
314        | hash (Index(a0,a1)) = 0w151 + hashty a0 + hashint a1        | hash (Zero(a0)) = 0w151 + hashty a0
315        | hash (Subscript(a0)) = 0w157 + hashty a0        | hash (Trace(a0)) = 0w157 + hashint a0
316        | hash (Ceiling(a0)) = 0w163 + hashint a0        | hash (Select(a0,a1)) = 0w163 + hashty a0 + hashint a1
317        | hash (Floor(a0)) = 0w167 + hashint a0        | hash (Index(a0,a1)) = 0w167 + hashty a0 + hashint a1
318        | hash (Round(a0)) = 0w173 + hashint a0        | hash (Subscript(a0)) = 0w173 + hashty a0
319        | hash (Trunc(a0)) = 0w179 + hashint a0        | hash (MkDynamic(a0,a1)) = 0w179 + hashty a0 + hashint a1
320        | hash IntToReal = 0w181        | hash (Append(a0)) = 0w181 + hashty a0
321        | hash (RealToInt(a0)) = 0w191 + hashint a0        | hash (Prepend(a0)) = 0w191 + hashty a0
322        | hash (VoxelAddress(a0,a1)) = 0w193 + ImageInfo.hash a0 + hashint a1        | hash (Concat(a0)) = 0w193 + hashty a0
323        | hash (LoadVoxels(a0,a1)) = 0w197 + ImageInfo.hash a0 + hashint a1        | hash (Length(a0)) = 0w197 + hashty a0
324        | hash (PosToImgSpace(a0)) = 0w199 + ImageInfo.hash a0        | hash (Ceiling(a0)) = 0w199 + hashint a0
325        | hash (TensorToWorldSpace(a0,a1)) = 0w211 + ImageInfo.hash a0 + hashty a1        | hash (Floor(a0)) = 0w211 + hashint a0
326        | hash (EvalKernel(a0,a1,a2)) = 0w223 + hashint a0 + Kernel.hash a1 + hashint a2        | hash (Round(a0)) = 0w223 + hashint a0
327        | hash (LoadImage(a0)) = 0w227 + ImageInfo.hash a0        | hash (Trunc(a0)) = 0w227 + hashint a0
328        | hash (Inside(a0,a1)) = 0w229 + ImageInfo.hash a0 + hashint a1        | hash IntToReal = 0w229
329        | hash (Input(a0,a1,a2)) = 0w233 + hashty a0 + hashstring a1 + hashstring a2        | hash (RealToInt(a0)) = 0w233 + hashint a0
330        | hash (InputWithDefault(a0,a1,a2)) = 0w239 + hashty a0 + hashstring a1 + hashstring a2        | hash (VoxelAddress(a0,a1)) = 0w239 + ImageInfo.hash a0 + hashint a1
331        | hash (Print(a0)) = 0w241 + hashtys a0        | hash (LoadVoxels(a0,a1)) = 0w241 + ImageInfo.hash a0 + hashint a1
332          | hash (PosToImgSpace(a0)) = 0w251 + ImageInfo.hash a0
333          | hash (TensorToWorldSpace(a0,a1)) = 0w257 + ImageInfo.hash a0 + hashty a1
334          | hash (EvalKernel(a0,a1,a2)) = 0w263 + hashint a0 + Kernel.hash a1 + hashint a2
335          | hash (Inside(a0,a1)) = 0w269 + ImageInfo.hash a0 + hashint a1
336          | hash (Input(a0)) = 0w271 + hashinput a0
337          | hash (Print(a0)) = 0w277 + hashtys a0
338    
339      fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]      fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]
340        | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]        | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]
# Line 321  Line 357 
357        | toString (MulVecMat(a0,a1)) = concat["MulVecMat<", intToString a0, ",", intToString a1, ">"]        | toString (MulVecMat(a0,a1)) = concat["MulVecMat<", intToString a0, ",", intToString a1, ">"]
358        | toString (MulMatVec(a0,a1)) = concat["MulMatVec<", intToString a0, ",", intToString a1, ">"]        | toString (MulMatVec(a0,a1)) = concat["MulMatVec<", intToString a0, ",", intToString a1, ">"]
359        | 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, ">"]
360          | toString (MulVecTen3(a0,a1,a2)) = concat["MulVecTen3<", intToString a0, ",", intToString a1, ",", intToString a2, ">"]
361          | toString (MulTen3Vec(a0,a1,a2)) = concat["MulTen3Vec<", intToString a0, ",", intToString a1, ",", intToString a2, ">"]
362          | toString (ColonMul(a0,a1)) = concat["ColonMul<", tyToString a0, ",", tyToString a1, ">"]
363        | toString Cross = "Cross"        | toString Cross = "Cross"
364        | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]        | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]
365        | toString (Normalize(a0)) = concat["Normalize<", intToString a0, ">"]        | toString (Normalize(a0)) = concat["Normalize<", intToString a0, ">"]
# Line 336  Line 375 
375        | toString (Select(a0,a1)) = concat["Select<", tyToString a0, ",", intToString a1, ">"]        | toString (Select(a0,a1)) = concat["Select<", tyToString a0, ",", intToString a1, ">"]
376        | toString (Index(a0,a1)) = concat["Index<", tyToString a0, ",", intToString a1, ">"]        | toString (Index(a0,a1)) = concat["Index<", tyToString a0, ",", intToString a1, ">"]
377        | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]        | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]
378          | toString (MkDynamic(a0,a1)) = concat["MkDynamic<", tyToString a0, ",", intToString a1, ">"]
379          | toString (Append(a0)) = concat["Append<", tyToString a0, ">"]
380          | toString (Prepend(a0)) = concat["Prepend<", tyToString a0, ">"]
381          | toString (Concat(a0)) = concat["Concat<", tyToString a0, ">"]
382          | toString (Length(a0)) = concat["Length<", tyToString a0, ">"]
383        | toString (Ceiling(a0)) = concat["Ceiling<", intToString a0, ">"]        | toString (Ceiling(a0)) = concat["Ceiling<", intToString a0, ">"]
384        | toString (Floor(a0)) = concat["Floor<", intToString a0, ">"]        | toString (Floor(a0)) = concat["Floor<", intToString a0, ">"]
385        | toString (Round(a0)) = concat["Round<", intToString a0, ">"]        | toString (Round(a0)) = concat["Round<", intToString a0, ">"]
# Line 347  Line 391 
391        | toString (PosToImgSpace(a0)) = concat["PosToImgSpace<", ImageInfo.toString a0, ">"]        | toString (PosToImgSpace(a0)) = concat["PosToImgSpace<", ImageInfo.toString a0, ">"]
392        | toString (TensorToWorldSpace(a0,a1)) = concat["TensorToWorldSpace<", ImageInfo.toString a0, ",", tyToString a1, ">"]        | toString (TensorToWorldSpace(a0,a1)) = concat["TensorToWorldSpace<", ImageInfo.toString a0, ",", tyToString a1, ">"]
393        | 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, ">"]  
394        | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"]        | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"]
395        | toString (Input(a0,a1,a2)) = concat["Input<", tyToString a0, ",", stringToString a1, ",", stringToString a2, ">"]        | toString (Input(a0)) = concat["Input<", inputToString a0, ">"]
       | toString (InputWithDefault(a0,a1,a2)) = concat["InputWithDefault<", tyToString a0, ",", stringToString a1, ",", stringToString a2, ">"]  
396        | toString (Print(a0)) = concat["Print<", tysToString a0, ">"]        | toString (Print(a0)) = concat["Print<", tysToString a0, ">"]
397    
398    end    end

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

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