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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/low-il/low-il.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/low-il/low-il.sml

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

revision 2522, Mon Jan 13 18:42:09 2014 UTC revision 2523, Fri Jan 17 19:25:37 2014 UTC
# Line 32  Line 32 
32      val hashstring = HashString.hashString      val hashstring = HashString.hashString
33      fun stringToString s = String.concat["\"", s, "\""]      fun stringToString s = String.concat["\"", s, "\""]
34    
  (* Was left out of my version  
  (* required helper functions for the input type *)  
  type input = ty Inputs.input  
  val sameinput = Inputs.same  
  val hashinput = Inputs.hash  
  val inputToString = Inputs.toString  
  *)  
   
35      datatype rator      datatype rator
36        = IAdd        = IAdd
37        | ISub        | ISub
# Line 56  Line 48 
48        | Not        | Not
49        | Max        | Max
50        | Min        | Min
51          | C of int
52          | V of int * ty
53          | S of int * ty
54          | addVec
55          | addSca
56          | subVec
57          | subSca
58          | prodVec
59          | prodSca
60          | prodScaV
61          | divSca
62          | sumVec
63          | cons of ty
64          | img of int * ty
65          | krn of int * int
66        | Clamp of ty        | Clamp of ty
67        | Lerp of ty        | Lerp of ty
68        | Norm of ty        | Norm of ty
# Line 80  Line 87 
87        | Trunc of int        | Trunc of int
88        | IntToReal        | IntToReal
89        | RealToInt of int        | RealToInt of int
90          | Transform of ImageInfo.info
91          (*Error here, could not find image)        | Translate of ImageInfo.info
       | Transform of Imageinfo.info  
       | Translate of Imageinfo.info*)  
   
92        | ImageAddress of ImageInfo.info        | ImageAddress of ImageInfo.info
93        | LoadVoxels of ImageInfo.info * int        | LoadVoxels of ImageInfo.info * int
94        | Inside of ImageInfo.info * int        | Inside of ImageInfo.info * int
95        | LoadSeq of ty * string        | LoadSeq of ty * string
96        | LoadImage of ty * string * ImageInfo.info        | LoadImage of ty * string * ImageInfo.info
   
         (*Input is not defined*)  
         (*| Input of input*)  
97        | Print of tys        | Print of tys
98    
99          (*gen types*)      fun resultArity IAdd = 1
100          | resultArity ISub = 1
101   | V of T  (*Projection of a Vector  *)        | resultArity IMul = 1
102   | S of T (*Specific row/col indo*)        | resultArity IDiv = 1
103   | C of int (*Constant, like ~1*)        | resultArity INeg = 1
  | addVec  
  | addSca  
  | subVec  
  | subSca  
  | prodVec  
  | prodSca  
  | prodScaV  
  | divSca  
  | sumVec  
  | cons  
  | img of T  
  | krn of int * int  
  withtype T=int*int list  
   
   
   
   
     fun resultArity (IAdd ) = 1  
       | resultArity (ISub ) = 1  
       | resultArity (IMul ) = 1  
       | resultArity (IDiv ) = 1  
       | resultArity (INeg ) = 1  
104        | resultArity (Abs _) = 1        | resultArity (Abs _) = 1
105        | resultArity (LT _) = 1        | resultArity (LT _) = 1
106        | resultArity (LTE _) = 1        | resultArity (LTE _) = 1
# Line 132  Line 111 
111        | resultArity Not = 1        | resultArity Not = 1
112        | resultArity Max = 1        | resultArity Max = 1
113        | resultArity Min = 1        | resultArity Min = 1
114          | resultArity (C _) = 1
115          | resultArity (V _) = 1
116          | resultArity (S _) = 1
117          | resultArity addVec = 1
118          | resultArity addSca = 1
119          | resultArity subVec = 1
120          | resultArity subSca = 1
121          | resultArity prodVec = 1
122          | resultArity prodSca = 1
123          | resultArity prodScaV = 1
124          | resultArity divSca = 1
125          | resultArity sumVec = 1
126          | resultArity (cons _) = 1
127          | resultArity (img _) = 1
128          | resultArity (krn _) = 1
129        | resultArity (Clamp _) = 1        | resultArity (Clamp _) = 1
130        | resultArity (Lerp _) = 1        | resultArity (Lerp _) = 1
131        | resultArity (Norm _) = 1        | resultArity (Norm _) = 1
# Line 156  Line 150 
150        | resultArity (Trunc _) = 1        | resultArity (Trunc _) = 1
151        | resultArity IntToReal = 1        | resultArity IntToReal = 1
152        | resultArity (RealToInt _) = 1        | resultArity (RealToInt _) = 1
153        (*| resultArity (Transform _) = 1        | resultArity (Transform _) = 1
154        | resultArity (Translate _) = 1*)        | resultArity (Translate _) = 1
155        | resultArity (ImageAddress _) = 1        | resultArity (ImageAddress _) = 1
156        | resultArity (LoadVoxels _) = 1        | resultArity (LoadVoxels _) = 1
157        | resultArity (Inside _) = 1        | resultArity (Inside _) = 1
158        | resultArity (LoadSeq _) = 1        | resultArity (LoadSeq _) = 1
159        | resultArity (LoadImage _) = 1        | resultArity (LoadImage _) = 1
       (*| resultArity (Input _) = 0*)  
160        | resultArity (Print _) = 0        | resultArity (Print _) = 0
161    
162      fun arity (IAdd ) = 2      fun arity IAdd = 2
163        | arity (ISub ) = 2        | arity ISub = 2
164        | arity (IMul ) = 2        | arity IMul = 2
165        | arity (IDiv ) = 2        | arity IDiv = 2
166        | arity (INeg ) = 1        | arity INeg = 1
167        | arity (Abs _) = 1        | arity (Abs _) = 1
168        | arity (LT _) = 2        | arity (LT _) = 2
169        | arity (LTE _) = 2        | arity (LTE _) = 2
# Line 181  Line 174 
174        | arity Not = 1        | arity Not = 1
175        | arity Max = 2        | arity Max = 2
176        | arity Min = 2        | arity Min = 2
177          | arity (C _) = 2
178          | arity (V _) = 2
179          | arity (S _) = 2
180          | arity addVec = 2
181          | arity addSca = 2
182          | arity subVec = 2
183          | arity subSca = 2
184          | arity prodVec = 2
185          | arity prodSca = 2
186          | arity prodScaV = 2
187          | arity divSca = 2
188          | arity sumVec = 2
189          | arity (cons _) = 2
190          | arity (img _) = 2
191          | arity (krn _) = 2
192        | arity (Clamp _) = 3        | arity (Clamp _) = 3
193        | arity (Lerp _) = 3        | arity (Lerp _) = 3
194        | arity (Norm _) = 1        | arity (Norm _) = 1
# Line 205  Line 213 
213        | arity (Trunc _) = 1        | arity (Trunc _) = 1
214        | arity IntToReal = 1        | arity IntToReal = 1
215        | arity (RealToInt _) = 1        | arity (RealToInt _) = 1
216        (*| arity (Transform _) = 2        | arity (Transform _) = 2
217        | arity (Translate _) = 2*)        | arity (Translate _) = 2
218        | arity (ImageAddress _) = 1        | arity (ImageAddress _) = 1
219        | arity (LoadVoxels _) = 1        | arity (LoadVoxels _) = 1
220        | arity (Inside _) = 2        | arity (Inside _) = 2
221        | arity (LoadSeq _) = 0        | arity (LoadSeq _) = 0
222        | arity (LoadImage _) = 0        | arity (LoadImage _) = 0
      (* | arity (Input _) = 0*)  
223        | arity (Print _) = ~1        | arity (Print _) = ~1
224    
225      fun isPure (MkDynamic _) = false      fun isPure (MkDynamic _) = false
# Line 237  Line 244 
244        | same (Not, Not) = true        | same (Not, Not) = true
245        | same (Max, Max) = true        | same (Max, Max) = true
246        | same (Min, Min) = true        | same (Min, Min) = true
247          | same (C(a0), C(b0)) = sameint(a0, b0)
248          | same (V(a0,a1), V(b0,b1)) = sameint(a0, b0) andalso samety(a1, b1)
249          | same (S(a0,a1), S(b0,b1)) = sameint(a0, b0) andalso samety(a1, b1)
250          | same (addVec, addVec) = true
251          | same (addSca, addSca) = true
252          | same (subVec, subVec) = true
253          | same (subSca, subSca) = true
254          | same (prodVec, prodVec) = true
255          | same (prodSca, prodSca) = true
256          | same (prodScaV, prodScaV) = true
257          | same (divSca, divSca) = true
258          | same (sumVec, sumVec) = true
259          | same (cons(a0), cons(b0)) = samety(a0, b0)
260          | same (img(a0,a1), img(b0,b1)) = sameint(a0, b0) andalso samety(a1, b1)
261          | same (krn(a0,a1), krn(b0,b1)) = sameint(a0, b0) andalso sameint(a1, b1)
262        | same (Clamp(a0), Clamp(b0)) = samety(a0, b0)        | same (Clamp(a0), Clamp(b0)) = samety(a0, b0)
263        | same (Lerp(a0), Lerp(b0)) = samety(a0, b0)        | same (Lerp(a0), Lerp(b0)) = samety(a0, b0)
264        | same (Norm(a0), Norm(b0)) = samety(a0, b0)        | same (Norm(a0), Norm(b0)) = samety(a0, b0)
# Line 261  Line 283 
283        | same (Trunc(a0), Trunc(b0)) = sameint(a0, b0)        | same (Trunc(a0), Trunc(b0)) = sameint(a0, b0)
284        | same (IntToReal, IntToReal) = true        | same (IntToReal, IntToReal) = true
285        | same (RealToInt(a0), RealToInt(b0)) = sameint(a0, b0)        | same (RealToInt(a0), RealToInt(b0)) = sameint(a0, b0)
286        (*| same (Transform(a0), Transform(b0)) = Imageinfo.same(a0, b0)        | same (Transform(a0), Transform(b0)) = ImageInfo.same(a0, b0)
287        | same (Translate(a0), Translate(b0)) = Imageinfo.same(a0, b0)*)        | same (Translate(a0), Translate(b0)) = ImageInfo.same(a0, b0)
288        | same (ImageAddress(a0), ImageAddress(b0)) = ImageInfo.same(a0, b0)        | same (ImageAddress(a0), ImageAddress(b0)) = ImageInfo.same(a0, b0)
289        | same (LoadVoxels(a0,a1), LoadVoxels(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1)        | same (LoadVoxels(a0,a1), LoadVoxels(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1)
290        | 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)
291        | same (LoadSeq(a0,a1), LoadSeq(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)        | same (LoadSeq(a0,a1), LoadSeq(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
292        | same (LoadImage(a0,a1,a2), LoadImage(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso ImageInfo.same(a2, b2)        | same (LoadImage(a0,a1,a2), LoadImage(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso ImageInfo.same(a2, b2)
       (*| same (Input(a0), Input(b0)) = sameinput(a0, b0)*)  
293        | same (Print(a0), Print(b0)) = sametys(a0, b0)        | same (Print(a0), Print(b0)) = sametys(a0, b0)
294        | same _ = false        | same _ = false
295    
296      fun hash (IAdd) = 0w3      fun hash IAdd = 0w3
297        | hash (ISub) = 0w5        | hash ISub = 0w5
298        | hash (IMul) = 0w7        | hash IMul = 0w7
299        | hash (IDiv) = 0w11        | hash IDiv = 0w11
300        | hash (INeg) = 0w13        | hash INeg = 0w13
301        | hash (Abs(a0)) = 0w17 + hashty a0        | hash (Abs(a0)) = 0w17 + hashty a0
302        | hash (LT(a0)) = 0w19 + hashty a0        | hash (LT(a0)) = 0w19 + hashty a0
303        | hash (LTE(a0)) = 0w23 + hashty a0        | hash (LTE(a0)) = 0w23 + hashty a0
# Line 287  Line 308 
308        | hash Not = 0w43        | hash Not = 0w43
309        | hash Max = 0w47        | hash Max = 0w47
310        | hash Min = 0w53        | hash Min = 0w53
311        | hash (Clamp(a0)) = 0w59 + hashty a0        | hash (C(a0)) = 0w59 + hashint a0
312        | hash (Lerp(a0)) = 0w61 + hashty a0        | hash (V(a0,a1)) = 0w61 + hashint a0 + hashty a1
313        | hash (Norm(a0)) = 0w67 + hashty a0        | hash (S(a0,a1)) = 0w67 + hashint a0 + hashty a1
314        | hash (Normalize(a0)) = 0w71 + hashint a0        | hash addVec = 0w71
315        | hash (PrincipleEvec(a0)) = 0w73 + hashty a0        | hash addSca = 0w73
316        | hash EigenVecs2x2 = 0w79        | hash subVec = 0w79
317        | hash EigenVecs3x3 = 0w83        | hash subSca = 0w83
318        | hash EigenVals2x2 = 0w89        | hash prodVec = 0w89
319        | hash EigenVals3x3 = 0w97        | hash prodSca = 0w97
320        | hash (Zero(a0)) = 0w101 + hashty a0        | hash prodScaV = 0w101
321        | hash (Select(a0,a1)) = 0w103 + hashty a0 + hashint a1        | hash divSca = 0w103
322        | hash (Index(a0,a1)) = 0w107 + hashty a0 + hashint a1        | hash sumVec = 0w107
323        | hash (Subscript(a0)) = 0w109 + hashty a0        | hash (cons(a0)) = 0w109 + hashty a0
324        | hash (MkDynamic(a0,a1)) = 0w113 + hashty a0 + hashint a1        | hash (img(a0,a1)) = 0w113 + hashint a0 + hashty a1
325        | hash (Append(a0)) = 0w127 + hashty a0        | hash (krn(a0,a1)) = 0w127 + hashint a0 + hashint a1
326        | hash (Prepend(a0)) = 0w131 + hashty a0        | hash (Clamp(a0)) = 0w131 + hashty a0
327        | hash (Concat(a0)) = 0w137 + hashty a0        | hash (Lerp(a0)) = 0w137 + hashty a0
328        | hash (Length(a0)) = 0w139 + hashty a0        | hash (Norm(a0)) = 0w139 + hashty a0
329        | hash (Ceiling(a0)) = 0w149 + hashint a0        | hash (Normalize(a0)) = 0w149 + hashint a0
330        | hash (Floor(a0)) = 0w151 + hashint a0        | hash (PrincipleEvec(a0)) = 0w151 + hashty a0
331        | hash (Round(a0)) = 0w157 + hashint a0        | hash EigenVecs2x2 = 0w157
332        | hash (Trunc(a0)) = 0w163 + hashint a0        | hash EigenVecs3x3 = 0w163
333        | hash IntToReal = 0w167        | hash EigenVals2x2 = 0w167
334        | hash (RealToInt(a0)) = 0w173 + hashint a0        | hash EigenVals3x3 = 0w173
335        (*| hash (Transform(a0)) = 0w179 + Imageinfo.hash a0        | hash (Zero(a0)) = 0w179 + hashty a0
336        | hash (Translate(a0)) = 0w181 + Imageinfo.hash a0*)        | hash (Select(a0,a1)) = 0w181 + hashty a0 + hashint a1
337        | hash (ImageAddress(a0)) = 0w191 + ImageInfo.hash a0        | hash (Index(a0,a1)) = 0w191 + hashty a0 + hashint a1
338        | hash (LoadVoxels(a0,a1)) = 0w193 + ImageInfo.hash a0 + hashint a1        | hash (Subscript(a0)) = 0w193 + hashty a0
339        | hash (Inside(a0,a1)) = 0w197 + ImageInfo.hash a0 + hashint a1        | hash (MkDynamic(a0,a1)) = 0w197 + hashty a0 + hashint a1
340        | hash (LoadSeq(a0,a1)) = 0w199 + hashty a0 + hashstring a1        | hash (Append(a0)) = 0w199 + hashty a0
341        | hash (LoadImage(a0,a1,a2)) = 0w211 + hashty a0 + hashstring a1 + ImageInfo.hash a2        | hash (Prepend(a0)) = 0w211 + hashty a0
342        (*| hash (Input(a0)) = 0w223 + hashinput a0*)        | hash (Concat(a0)) = 0w223 + hashty a0
343        | hash (Print(a0)) = 0w227 + hashtys a0        | hash (Length(a0)) = 0w227 + hashty a0
344          | hash (Ceiling(a0)) = 0w229 + hashint a0
345          | hash (Floor(a0)) = 0w233 + hashint a0
346      fun intList(ix)=String.concat (List.map (fn(e)=>Int.toString(e)) ix)        | hash (Round(a0)) = 0w239 + hashint a0
347          | hash (Trunc(a0)) = 0w241 + hashint a0
348      fun toString (IAdd) = concat["IAdd"]        | hash IntToReal = 0w251
349        | toString (ISub) = concat["ISub"]        | hash (RealToInt(a0)) = 0w257 + hashint a0
350        | toString (IMul) = concat["IMul"]        | hash (Transform(a0)) = 0w263 + ImageInfo.hash a0
351        | toString (IDiv) = concat["IDiv"]        | hash (Translate(a0)) = 0w269 + ImageInfo.hash a0
352        | toString (INeg) = concat["INeg"]        | hash (ImageAddress(a0)) = 0w271 + ImageInfo.hash a0
353          | hash (LoadVoxels(a0,a1)) = 0w277 + ImageInfo.hash a0 + hashint a1
354          | hash (Inside(a0,a1)) = 0w281 + ImageInfo.hash a0 + hashint a1
355          | hash (LoadSeq(a0,a1)) = 0w283 + hashty a0 + hashstring a1
356          | hash (LoadImage(a0,a1,a2)) = 0w293 + hashty a0 + hashstring a1 + ImageInfo.hash a2
357          | hash (Print(a0)) = 0w307 + hashtys a0
358    
359        fun toString IAdd = "IAdd"
360          | toString ISub = "ISub"
361          | toString IMul = "IMul"
362          | toString IDiv = "IDiv"
363          | toString INeg = "INeg"
364        | toString (Abs(a0)) = concat["Abs<", tyToString a0, ">"]        | toString (Abs(a0)) = concat["Abs<", tyToString a0, ">"]
365        | toString (LT(a0)) = concat["LT<", tyToString a0, ">"]        | toString (LT(a0)) = concat["LT<", tyToString a0, ">"]
366        | toString (LTE(a0)) = concat["LTE<", tyToString a0, ">"]        | toString (LTE(a0)) = concat["LTE<", tyToString a0, ">"]
# Line 339  Line 371 
371        | toString Not = "Not"        | toString Not = "Not"
372        | toString Max = "Max"        | toString Max = "Max"
373        | toString Min = "Min"        | toString Min = "Min"
374          | toString (C(a0)) = concat["C<", intToString a0, ">"]
375          | toString (V(a0,a1)) = concat["V<", intToString a0, ",", tyToString a1, ">"]
376          | toString (S(a0,a1)) = concat["S<", intToString a0, ",", tyToString a1, ">"]
377          | toString addVec = "addVec"
378          | toString addSca = "addSca"
379          | toString subVec = "subVec"
380          | toString subSca = "subSca"
381          | toString prodVec = "prodVec"
382          | toString prodSca = "prodSca"
383          | toString prodScaV = "prodScaV"
384          | toString divSca = "divSca"
385          | toString sumVec = "sumVec"
386          | toString (cons(a0)) = concat["cons<", tyToString a0, ">"]
387          | toString (img(a0,a1)) = concat["img<", intToString a0, ",", tyToString a1, ">"]
388          | toString (krn(a0,a1)) = concat["krn<", intToString a0, ",", intToString a1, ">"]
389        | toString (Clamp(a0)) = concat["Clamp<", tyToString a0, ">"]        | toString (Clamp(a0)) = concat["Clamp<", tyToString a0, ">"]
390        | toString (Lerp(a0)) = concat["Lerp<", tyToString a0, ">"]        | toString (Lerp(a0)) = concat["Lerp<", tyToString a0, ">"]
391        | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]        | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]
# Line 363  Line 410 
410        | toString (Trunc(a0)) = concat["Trunc<", intToString a0, ">"]        | toString (Trunc(a0)) = concat["Trunc<", intToString a0, ">"]
411        | toString IntToReal = "IntToReal"        | toString IntToReal = "IntToReal"
412        | toString (RealToInt(a0)) = concat["RealToInt<", intToString a0, ">"]        | toString (RealToInt(a0)) = concat["RealToInt<", intToString a0, ">"]
413       (* | toString (Transform(a0)) = concat["Transform<", Imageinfo.toString a0, ">"]        | toString (Transform(a0)) = concat["Transform<", ImageInfo.toString a0, ">"]
414        | toString (Translate(a0)) = concat["Translate<", Imageinfo.toString a0, ">"]*)        | toString (Translate(a0)) = concat["Translate<", ImageInfo.toString a0, ">"]
415        | toString (ImageAddress(a0)) = concat["ImageAddress<", ImageInfo.toString a0, ">"]        | toString (ImageAddress(a0)) = concat["ImageAddress<", ImageInfo.toString a0, ">"]
416        | toString (LoadVoxels(a0,a1)) = concat["LoadVoxels<", ImageInfo.toString a0, ",", intToString a1, ">"]        | toString (LoadVoxels(a0,a1)) = concat["LoadVoxels<", ImageInfo.toString a0, ",", intToString a1, ">"]
417        | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"]        | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"]
418        | toString (LoadSeq(a0,a1)) = concat["LoadSeq<", tyToString a0, ",", stringToString a1, ">"]        | toString (LoadSeq(a0,a1)) = concat["LoadSeq<", tyToString a0, ",", stringToString a1, ">"]
419        | toString (LoadImage(a0,a1,a2)) = concat["LoadImage<", tyToString a0, ",", stringToString a1, ",", ImageInfo.toString a2, ">"]        | toString (LoadImage(a0,a1,a2)) = concat["LoadImage<", tyToString a0, ",", stringToString a1, ",", ImageInfo.toString a2, ">"]
       (*| toString (Input(a0)) = concat["Input<", inputToString a0, ">"]*)  
         | toString(V(id,ix))=concat["Projection:",Int.toString(id)," at ",(intList ix)," "]  
         | toString(S (id,ix))=concat["Sca:",Int.toString(id)," at ",(intList ix)," "]  
           | toString(C c)=concat["Const: ",Int.toString(c)," "]  
           | toString(addVec)="AddVec"  
           | toString(addSca)="addSca"  
           | toString(subVec)="SubVec"  
           | toString(subSca)="SubSca"  
           | toString(prodVec)="ProdVec"  
           | toString(prodSca)="ProdSca"  
           | toString(prodScaV)="ProdScaV"  
           | toString(divSca)="DivSca"  
           | toString(sumVec)="SumVec"  
           | toString(cons)="Cons"  
         | toString(img (id,ix))=concat["Image:",Int.toString(id)," at ",(intList ix)," "]  
           | toString(krn _)="Krn"  
420            | toString (Print(a0)) = concat["Print<", tysToString a0, ">"]            | toString (Print(a0)) = concat["Print<", tysToString a0, ">"]
421    
   
   
422    end    end
423    
424  structure LowIL = SSAFn(  structure LowIL = SSAFn(

Legend:
Removed from v.2522  
changed lines
  Added in v.2523

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