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

revision 1301, Thu Jun 9 23:58:40 2011 UTC revision 1640, Wed Nov 16 02:19:51 2011 UTC
# Line 11  Line 11 
11  structure MidOps =  structure MidOps =
12    struct    struct
13    
14      (* required helper functions for types *)
15      type ty = MidILTypes.ty      type ty = MidILTypes.ty
   
16      val samety = MidILTypes.same      val samety = MidILTypes.same
17      val hashty = MidILTypes.hash      val hashty = MidILTypes.hash
18      val tyToString = MidILTypes.toString      val tyToString = MidILTypes.toString
19    
20      (* required helper functions for type lists *)
21        type tys = ty list
22        fun sametys (tys1, tys2) = ListPair.allEq samety (tys1, tys2)
23        fun hashtys tys = List.foldl (fn (ty, s) => hashty ty + 0w3 * s) 0w0 tys
24        fun tysToString tys = String.concat["[", String.concatWith "," (List.map tyToString tys), "]" ]
25    
26    (* required helper functions for the int type *)    (* required helper functions for the int type *)
27      fun sameint (i1 : int, i2) = (i1 = i2)      fun sameint (i1 : int, i2) = (i1 = i2)
28      fun hashint i = Word.fromInt i      fun hashint i = Word.fromInt i
# Line 50  Line 56 
56        | MulMatVec of int * int        | MulMatVec of int * int
57        | MulMatMat of int * int * int        | MulMatMat of int * int * int
58        | Cross        | Cross
       | Select of ty * int  
59        | Norm of ty        | Norm of ty
60        | Normalize of int        | Normalize of int
61        | Scale of ty        | Scale of ty
       | CL  
62        | PrincipleEvec of ty        | PrincipleEvec of ty
63          | EigenVecs2x2
64          | EigenVecs3x3
65          | EigenVals2x2
66          | EigenVals3x3
67        | Identity of int        | Identity of int
68        | Zero of ty        | Zero of ty
69        | Trace of int        | Trace of int
70          | Select of ty * int
71          | Index of ty * int
72        | Subscript of ty        | Subscript of ty
73        | Ceiling of int        | Ceiling of int
74        | Floor of int        | Floor of int
# Line 75  Line 85 
85        | Inside of ImageInfo.info * int        | Inside of ImageInfo.info * int
86        | Input of ty * string * string        | Input of ty * string * string
87        | InputWithDefault of ty * string * string        | InputWithDefault of ty * string * string
88          | Print of tys
89    
90        fun resultArity (Add _) = 1
91          | resultArity (Sub _) = 1
92          | resultArity (Mul _) = 1
93          | resultArity (Div _) = 1
94          | resultArity (Neg _) = 1
95          | resultArity (Abs _) = 1
96          | resultArity (LT _) = 1
97          | resultArity (LTE _) = 1
98          | resultArity (EQ _) = 1
99          | resultArity (NEQ _) = 1
100          | resultArity (GT _) = 1
101          | resultArity (GTE _) = 1
102          | resultArity Not = 1
103          | resultArity Max = 1
104          | resultArity Min = 1
105          | resultArity (Clamp _) = 1
106          | resultArity (Lerp _) = 1
107          | resultArity (Dot _) = 1
108          | resultArity (MulVecMat _) = 1
109          | resultArity (MulMatVec _) = 1
110          | resultArity (MulMatMat _) = 1
111          | resultArity Cross = 1
112          | resultArity (Norm _) = 1
113          | resultArity (Normalize _) = 1
114          | resultArity (Scale _) = 1
115          | resultArity (PrincipleEvec _) = 1
116          | resultArity EigenVecs2x2 = 1
117          | resultArity EigenVecs3x3 = 1
118          | resultArity EigenVals2x2 = 1
119          | resultArity EigenVals3x3 = 1
120          | resultArity (Identity _) = 1
121          | resultArity (Zero _) = 1
122          | resultArity (Trace _) = 1
123          | resultArity (Select _) = 1
124          | resultArity (Index _) = 1
125          | resultArity (Subscript _) = 1
126          | resultArity (Ceiling _) = 1
127          | resultArity (Floor _) = 1
128          | resultArity (Round _) = 1
129          | resultArity (Trunc _) = 1
130          | resultArity IntToReal = 1
131          | resultArity (RealToInt _) = 1
132          | resultArity (VoxelAddress _) = 1
133          | resultArity (LoadVoxels _) = 1
134          | resultArity (PosToImgSpace _) = 1
135          | resultArity (TensorToWorldSpace _) = 1
136          | resultArity (EvalKernel _) = 1
137          | resultArity (LoadImage _) = 1
138          | resultArity (Inside _) = 1
139          | resultArity (Input _) = 1
140          | resultArity (InputWithDefault _) = 1
141          | resultArity (Print _) = 0
142    
143      fun arity (Add _) = 2      fun arity (Add _) = 2
144        | arity (Sub _) = 2        | arity (Sub _) = 2
# Line 98  Line 162 
162        | arity (MulMatVec _) = 2        | arity (MulMatVec _) = 2
163        | arity (MulMatMat _) = 2        | arity (MulMatMat _) = 2
164        | arity Cross = 2        | arity Cross = 2
       | arity (Select _) = 1  
165        | arity (Norm _) = 1        | arity (Norm _) = 1
166        | arity (Normalize _) = 1        | arity (Normalize _) = 1
167        | arity (Scale _) = 2        | arity (Scale _) = 2
       | arity CL = 1  
168        | arity (PrincipleEvec _) = 2        | arity (PrincipleEvec _) = 2
169          | arity EigenVecs2x2 = 1
170          | arity EigenVecs3x3 = 1
171          | arity EigenVals2x2 = 1
172          | arity EigenVals3x3 = 1
173        | arity (Identity _) = 0        | arity (Identity _) = 0
174        | arity (Zero _) = 0        | arity (Zero _) = 0
175        | arity (Trace _) = 1        | arity (Trace _) = 1
176          | arity (Select _) = 1
177          | arity (Index _) = 1
178        | arity (Subscript _) = 2        | arity (Subscript _) = 2
179        | arity (Ceiling _) = 1        | arity (Ceiling _) = 1
180        | arity (Floor _) = 1        | arity (Floor _) = 1
# Line 123  Line 191 
191        | arity (Inside _) = 2        | arity (Inside _) = 2
192        | arity (Input _) = 0        | arity (Input _) = 0
193        | arity (InputWithDefault _) = 1        | arity (InputWithDefault _) = 1
194          | arity (Print _) = ~1
195    
196      fun same (Add(a0), Add(b0)) = samety(a0, b0)      fun same (Add(a0), Add(b0)) = samety(a0, b0)
197        | same (Sub(a0), Sub(b0)) = samety(a0, b0)        | same (Sub(a0), Sub(b0)) = samety(a0, b0)
# Line 146  Line 215 
215        | 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)
216        | 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)
217        | same (Cross, Cross) = true        | same (Cross, Cross) = true
       | same (Select(a0,a1), Select(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1)  
218        | same (Norm(a0), Norm(b0)) = samety(a0, b0)        | same (Norm(a0), Norm(b0)) = samety(a0, b0)
219        | same (Normalize(a0), Normalize(b0)) = sameint(a0, b0)        | same (Normalize(a0), Normalize(b0)) = sameint(a0, b0)
220        | same (Scale(a0), Scale(b0)) = samety(a0, b0)        | same (Scale(a0), Scale(b0)) = samety(a0, b0)
       | same (CL, CL) = true  
221        | same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0)        | same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0)
222          | same (EigenVecs2x2, EigenVecs2x2) = true
223          | same (EigenVecs3x3, EigenVecs3x3) = true
224          | same (EigenVals2x2, EigenVals2x2) = true
225          | same (EigenVals3x3, EigenVals3x3) = true
226        | same (Identity(a0), Identity(b0)) = sameint(a0, b0)        | same (Identity(a0), Identity(b0)) = sameint(a0, b0)
227        | same (Zero(a0), Zero(b0)) = samety(a0, b0)        | same (Zero(a0), Zero(b0)) = samety(a0, b0)
228        | same (Trace(a0), Trace(b0)) = sameint(a0, b0)        | same (Trace(a0), Trace(b0)) = sameint(a0, b0)
229          | same (Select(a0,a1), Select(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1)
230          | same (Index(a0,a1), Index(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1)
231        | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)        | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)
232        | same (Ceiling(a0), Ceiling(b0)) = sameint(a0, b0)        | same (Ceiling(a0), Ceiling(b0)) = sameint(a0, b0)
233        | same (Floor(a0), Floor(b0)) = sameint(a0, b0)        | same (Floor(a0), Floor(b0)) = sameint(a0, b0)
# Line 171  Line 244 
244        | 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)
245        | same (Input(a0,a1,a2), Input(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso samestring(a2, b2)        | same (Input(a0,a1,a2), Input(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso samestring(a2, b2)
246        | same (InputWithDefault(a0,a1,a2), InputWithDefault(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso samestring(a2, b2)        | same (InputWithDefault(a0,a1,a2), InputWithDefault(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso samestring(a2, b2)
247          | same (Print(a0), Print(b0)) = sametys(a0, b0)
248        | same _ = false        | same _ = false
249    
250      fun hash (Add(a0)) = 0w3 + hashty a0      fun hash (Add(a0)) = 0w3 + hashty a0
# Line 195  Line 269 
269        | hash (MulMatVec(a0,a1)) = 0w73 + hashint a0 + hashint a1        | hash (MulMatVec(a0,a1)) = 0w73 + hashint a0 + hashint a1
270        | hash (MulMatMat(a0,a1,a2)) = 0w79 + hashint a0 + hashint a1 + hashint a2        | hash (MulMatMat(a0,a1,a2)) = 0w79 + hashint a0 + hashint a1 + hashint a2
271        | hash Cross = 0w83        | hash Cross = 0w83
272        | hash (Select(a0,a1)) = 0w89 + hashty a0 + hashint a1        | hash (Norm(a0)) = 0w89 + hashty a0
273        | hash (Norm(a0)) = 0w97 + hashty a0        | hash (Normalize(a0)) = 0w97 + hashint a0
274        | hash (Normalize(a0)) = 0w101 + hashint a0        | hash (Scale(a0)) = 0w101 + hashty a0
275        | hash (Scale(a0)) = 0w103 + hashty a0        | hash (PrincipleEvec(a0)) = 0w103 + hashty a0
276        | hash CL = 0w107        | hash EigenVecs2x2 = 0w107
277        | hash (PrincipleEvec(a0)) = 0w109 + hashty a0        | hash EigenVecs3x3 = 0w109
278        | hash (Identity(a0)) = 0w113 + hashint a0        | hash EigenVals2x2 = 0w113
279        | hash (Zero(a0)) = 0w127 + hashty a0        | hash EigenVals3x3 = 0w127
280        | hash (Trace(a0)) = 0w131 + hashint a0        | hash (Identity(a0)) = 0w131 + hashint a0
281        | hash (Subscript(a0)) = 0w137 + hashty a0        | hash (Zero(a0)) = 0w137 + hashty a0
282        | hash (Ceiling(a0)) = 0w139 + hashint a0        | hash (Trace(a0)) = 0w139 + hashint a0
283        | hash (Floor(a0)) = 0w149 + hashint a0        | hash (Select(a0,a1)) = 0w149 + hashty a0 + hashint a1
284        | hash (Round(a0)) = 0w151 + hashint a0        | hash (Index(a0,a1)) = 0w151 + hashty a0 + hashint a1
285        | hash (Trunc(a0)) = 0w157 + hashint a0        | hash (Subscript(a0)) = 0w157 + hashty a0
286        | hash IntToReal = 0w163        | hash (Ceiling(a0)) = 0w163 + hashint a0
287        | hash (RealToInt(a0)) = 0w167 + hashint a0        | hash (Floor(a0)) = 0w167 + hashint a0
288        | hash (VoxelAddress(a0,a1)) = 0w173 + ImageInfo.hash a0 + hashint a1        | hash (Round(a0)) = 0w173 + hashint a0
289        | hash (LoadVoxels(a0,a1)) = 0w179 + ImageInfo.hash a0 + hashint a1        | hash (Trunc(a0)) = 0w179 + hashint a0
290        | hash (PosToImgSpace(a0)) = 0w181 + ImageInfo.hash a0        | hash IntToReal = 0w181
291        | hash (TensorToWorldSpace(a0,a1)) = 0w191 + ImageInfo.hash a0 + hashty a1        | hash (RealToInt(a0)) = 0w191 + hashint a0
292        | hash (EvalKernel(a0,a1,a2)) = 0w193 + hashint a0 + Kernel.hash a1 + hashint a2        | hash (VoxelAddress(a0,a1)) = 0w193 + ImageInfo.hash a0 + hashint a1
293        | hash (LoadImage(a0)) = 0w197 + ImageInfo.hash a0        | hash (LoadVoxels(a0,a1)) = 0w197 + ImageInfo.hash a0 + hashint a1
294        | hash (Inside(a0,a1)) = 0w199 + ImageInfo.hash a0 + hashint a1        | hash (PosToImgSpace(a0)) = 0w199 + ImageInfo.hash a0
295        | hash (Input(a0,a1,a2)) = 0w211 + hashty a0 + hashstring a1 + hashstring a2        | hash (TensorToWorldSpace(a0,a1)) = 0w211 + ImageInfo.hash a0 + hashty a1
296        | hash (InputWithDefault(a0,a1,a2)) = 0w223 + hashty a0 + hashstring a1 + hashstring a2        | hash (EvalKernel(a0,a1,a2)) = 0w223 + hashint a0 + Kernel.hash a1 + hashint a2
297          | hash (LoadImage(a0)) = 0w227 + ImageInfo.hash a0
298          | hash (Inside(a0,a1)) = 0w229 + ImageInfo.hash a0 + hashint a1
299          | hash (Input(a0,a1,a2)) = 0w233 + hashty a0 + hashstring a1 + hashstring a2
300          | hash (InputWithDefault(a0,a1,a2)) = 0w239 + hashty a0 + hashstring a1 + hashstring a2
301          | hash (Print(a0)) = 0w241 + hashtys a0
302    
303      fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]      fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]
304        | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]        | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]
# Line 243  Line 322 
322        | toString (MulMatVec(a0,a1)) = concat["MulMatVec<", intToString a0, ",", intToString a1, ">"]        | toString (MulMatVec(a0,a1)) = concat["MulMatVec<", intToString a0, ",", intToString a1, ">"]
323        | 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, ">"]
324        | toString Cross = "Cross"        | toString Cross = "Cross"
       | toString (Select(a0,a1)) = concat["Select<", tyToString a0, ",", intToString a1, ">"]  
325        | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]        | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]
326        | toString (Normalize(a0)) = concat["Normalize<", intToString a0, ">"]        | toString (Normalize(a0)) = concat["Normalize<", intToString a0, ">"]
327        | toString (Scale(a0)) = concat["Scale<", tyToString a0, ">"]        | toString (Scale(a0)) = concat["Scale<", tyToString a0, ">"]
       | toString CL = "CL"  
328        | toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"]        | toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"]
329          | toString EigenVecs2x2 = "EigenVecs2x2"
330          | toString EigenVecs3x3 = "EigenVecs3x3"
331          | toString EigenVals2x2 = "EigenVals2x2"
332          | toString EigenVals3x3 = "EigenVals3x3"
333        | toString (Identity(a0)) = concat["Identity<", intToString a0, ">"]        | toString (Identity(a0)) = concat["Identity<", intToString a0, ">"]
334        | toString (Zero(a0)) = concat["Zero<", tyToString a0, ">"]        | toString (Zero(a0)) = concat["Zero<", tyToString a0, ">"]
335        | toString (Trace(a0)) = concat["Trace<", intToString a0, ">"]        | toString (Trace(a0)) = concat["Trace<", intToString a0, ">"]
336          | toString (Select(a0,a1)) = concat["Select<", tyToString a0, ",", intToString a1, ">"]
337          | toString (Index(a0,a1)) = concat["Index<", tyToString a0, ",", intToString a1, ">"]
338        | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]        | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]
339        | toString (Ceiling(a0)) = concat["Ceiling<", intToString a0, ">"]        | toString (Ceiling(a0)) = concat["Ceiling<", intToString a0, ">"]
340        | toString (Floor(a0)) = concat["Floor<", intToString a0, ">"]        | toString (Floor(a0)) = concat["Floor<", intToString a0, ">"]
# Line 268  Line 351 
351        | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"]        | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"]
352        | toString (Input(a0,a1,a2)) = concat["Input<", tyToString a0, ",", stringToString a1, ",", stringToString a2, ">"]        | toString (Input(a0,a1,a2)) = concat["Input<", tyToString a0, ",", stringToString a1, ",", stringToString a2, ">"]
353        | toString (InputWithDefault(a0,a1,a2)) = concat["InputWithDefault<", tyToString a0, ",", stringToString a1, ",", stringToString a2, ">"]        | toString (InputWithDefault(a0,a1,a2)) = concat["InputWithDefault<", tyToString a0, ",", stringToString a1, ",", stringToString a2, ">"]
354          | toString (Print(a0)) = concat["Print<", tysToString a0, ">"]
355    
356    end    end
357    

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

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