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 2414, Mon Aug 19 05:02:14 2013 UTC revision 2522, Mon Jan 13 18:42:09 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    
35     (* Was left out of my version
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    
43      datatype rator      datatype rator
44        = IAdd of ty        = IAdd
45        | ISub of ty        | ISub
46        | IMul of ty        | IMul
47        | IDiv of ty        | IDiv
48        | INeg of ty        | INeg
49        | Abs of ty        | Abs of ty
50        | LT of ty        | LT of ty
51        | LTE of ty        | LTE of ty
# Line 72  Line 80 
80        | Trunc of int        | Trunc of int
81        | IntToReal        | IntToReal
82        | RealToInt of int        | RealToInt of int
83    
84            (*Error here, could not find image)
85        | Transform of Imageinfo.info        | Transform of Imageinfo.info
86        | Translate of Imageinfo.info        | Translate of Imageinfo.info*)
87    
88        | ImageAddress of ImageInfo.info        | ImageAddress of ImageInfo.info
89        | LoadVoxels of ImageInfo.info * int        | LoadVoxels of ImageInfo.info * int
90        | Inside of ImageInfo.info * int        | Inside of ImageInfo.info * int
91        | LoadSeq of ty * string        | LoadSeq of ty * string
92        | LoadImage of ty * string * ImageInfo.info        | LoadImage of ty * string * ImageInfo.info
93        | Input of input  
94            (*Input is not defined*)
95            (*| Input of input*)
96        | Print of tys        | Print of tys
97    
98      fun resultArity (IAdd _) = 1          (*gen types*)
99        | resultArity (ISub _) = 1  
100        | resultArity (IMul _) = 1   | V of T  (*Projection of a Vector  *)
101        | resultArity (IDiv _) = 1   | S of T (*Specific row/col indo*)
102        | resultArity (INeg _) = 1   | C of int (*Constant, like ~1*)
103     | addVec
104     | addSca
105     | subVec
106     | subSca
107     | prodVec
108     | prodSca
109     | prodScaV
110     | divSca
111     | sumVec
112     | cons
113     | img of T
114     | krn of int * int
115     withtype T=int*int list
116    
117    
118    
119    
120        fun resultArity (IAdd ) = 1
121          | resultArity (ISub ) = 1
122          | resultArity (IMul ) = 1
123          | resultArity (IDiv ) = 1
124          | resultArity (INeg ) = 1
125        | resultArity (Abs _) = 1        | resultArity (Abs _) = 1
126        | resultArity (LT _) = 1        | resultArity (LT _) = 1
127        | resultArity (LTE _) = 1        | resultArity (LTE _) = 1
# Line 121  Line 156 
156        | resultArity (Trunc _) = 1        | resultArity (Trunc _) = 1
157        | resultArity IntToReal = 1        | resultArity IntToReal = 1
158        | resultArity (RealToInt _) = 1        | resultArity (RealToInt _) = 1
159        | resultArity (Transform _) = 1        (*| resultArity (Transform _) = 1
160        | resultArity (Translate _) = 1        | resultArity (Translate _) = 1*)
161        | resultArity (ImageAddress _) = 1        | resultArity (ImageAddress _) = 1
162        | resultArity (LoadVoxels _) = 1        | resultArity (LoadVoxels _) = 1
163        | resultArity (Inside _) = 1        | resultArity (Inside _) = 1
164        | resultArity (LoadSeq _) = 1        | resultArity (LoadSeq _) = 1
165        | resultArity (LoadImage _) = 1        | resultArity (LoadImage _) = 1
166        | resultArity (Input _) = 0        (*| resultArity (Input _) = 0*)
167        | resultArity (Print _) = 0        | resultArity (Print _) = 0
168    
169      fun arity (IAdd _) = 2      fun arity (IAdd ) = 2
170        | arity (ISub _) = 2        | arity (ISub ) = 2
171        | arity (IMul _) = 2        | arity (IMul ) = 2
172        | arity (IDiv _) = 2        | arity (IDiv ) = 2
173        | arity (INeg _) = 1        | arity (INeg ) = 1
174        | arity (Abs _) = 1        | arity (Abs _) = 1
175        | arity (LT _) = 2        | arity (LT _) = 2
176        | arity (LTE _) = 2        | arity (LTE _) = 2
# Line 170  Line 205 
205        | arity (Trunc _) = 1        | arity (Trunc _) = 1
206        | arity IntToReal = 1        | arity IntToReal = 1
207        | arity (RealToInt _) = 1        | arity (RealToInt _) = 1
208        | arity (Transform _) = 2        (*| arity (Transform _) = 2
209        | arity (Translate _) = 2        | arity (Translate _) = 2*)
210        | arity (ImageAddress _) = 1        | arity (ImageAddress _) = 1
211        | arity (LoadVoxels _) = 1        | arity (LoadVoxels _) = 1
212        | arity (Inside _) = 2        | arity (Inside _) = 2
213        | arity (LoadSeq _) = 0        | arity (LoadSeq _) = 0
214        | arity (LoadImage _) = 0        | arity (LoadImage _) = 0
215        | arity (Input _) = 0       (* | arity (Input _) = 0*)
216        | arity (Print _) = ~1        | arity (Print _) = ~1
217    
218      fun isPure (MkDynamic _) = false      fun isPure (MkDynamic _) = false
# Line 187  Line 222 
222        | isPure (Print _) = false        | isPure (Print _) = false
223        | isPure _ = true        | isPure _ = true
224    
225      fun same (IAdd(a0), IAdd(b0)) = samety(a0, b0)      fun same (IAdd, IAdd) = true
226        | same (ISub(a0), ISub(b0)) = samety(a0, b0)        | same (ISub, ISub) = true
227        | same (IMul(a0), IMul(b0)) = samety(a0, b0)        | same (IMul, IMul) = true
228        | same (IDiv(a0), IDiv(b0)) = samety(a0, b0)        | same (IDiv, IDiv) = true
229        | same (INeg(a0), INeg(b0)) = samety(a0, b0)        | same (INeg, INeg) = true
230        | same (Abs(a0), Abs(b0)) = samety(a0, b0)        | same (Abs(a0), Abs(b0)) = samety(a0, b0)
231        | same (LT(a0), LT(b0)) = samety(a0, b0)        | same (LT(a0), LT(b0)) = samety(a0, b0)
232        | same (LTE(a0), LTE(b0)) = samety(a0, b0)        | same (LTE(a0), LTE(b0)) = samety(a0, b0)
# Line 226  Line 261 
261        | same (Trunc(a0), Trunc(b0)) = sameint(a0, b0)        | same (Trunc(a0), Trunc(b0)) = sameint(a0, b0)
262        | same (IntToReal, IntToReal) = true        | same (IntToReal, IntToReal) = true
263        | same (RealToInt(a0), RealToInt(b0)) = sameint(a0, b0)        | same (RealToInt(a0), RealToInt(b0)) = sameint(a0, b0)
264        | same (Transform(a0), Transform(b0)) = Imageinfo.same(a0, b0)        (*| same (Transform(a0), Transform(b0)) = Imageinfo.same(a0, b0)
265        | same (Translate(a0), Translate(b0)) = Imageinfo.same(a0, b0)        | same (Translate(a0), Translate(b0)) = Imageinfo.same(a0, b0)*)
266        | same (ImageAddress(a0), ImageAddress(b0)) = ImageInfo.same(a0, b0)        | same (ImageAddress(a0), ImageAddress(b0)) = ImageInfo.same(a0, b0)
267        | 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)
268        | 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)
269        | 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)
270        | 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)
271        | same (Input(a0), Input(b0)) = sameinput(a0, b0)        (*| same (Input(a0), Input(b0)) = sameinput(a0, b0)*)
272        | same (Print(a0), Print(b0)) = sametys(a0, b0)        | same (Print(a0), Print(b0)) = sametys(a0, b0)
273        | same _ = false        | same _ = false
274    
275      fun hash (IAdd(a0)) = 0w3 + hashty a0      fun hash (IAdd) = 0w3
276        | hash (ISub(a0)) = 0w5 + hashty a0        | hash (ISub) = 0w5
277        | hash (IMul(a0)) = 0w7 + hashty a0        | hash (IMul) = 0w7
278        | hash (IDiv(a0)) = 0w11 + hashty a0        | hash (IDiv) = 0w11
279        | hash (INeg(a0)) = 0w13 + hashty a0        | hash (INeg) = 0w13
280        | hash (Abs(a0)) = 0w17 + hashty a0        | hash (Abs(a0)) = 0w17 + hashty a0
281        | hash (LT(a0)) = 0w19 + hashty a0        | hash (LT(a0)) = 0w19 + hashty a0
282        | hash (LTE(a0)) = 0w23 + hashty a0        | hash (LTE(a0)) = 0w23 + hashty a0
# Line 276  Line 311 
311        | hash (Trunc(a0)) = 0w163 + hashint a0        | hash (Trunc(a0)) = 0w163 + hashint a0
312        | hash IntToReal = 0w167        | hash IntToReal = 0w167
313        | hash (RealToInt(a0)) = 0w173 + hashint a0        | hash (RealToInt(a0)) = 0w173 + hashint a0
314        | hash (Transform(a0)) = 0w179 + Imageinfo.hash a0        (*| hash (Transform(a0)) = 0w179 + Imageinfo.hash a0
315        | hash (Translate(a0)) = 0w181 + Imageinfo.hash a0        | hash (Translate(a0)) = 0w181 + Imageinfo.hash a0*)
316        | hash (ImageAddress(a0)) = 0w191 + ImageInfo.hash a0        | hash (ImageAddress(a0)) = 0w191 + ImageInfo.hash a0
317        | hash (LoadVoxels(a0,a1)) = 0w193 + ImageInfo.hash a0 + hashint a1        | hash (LoadVoxels(a0,a1)) = 0w193 + ImageInfo.hash a0 + hashint a1
318        | hash (Inside(a0,a1)) = 0w197 + ImageInfo.hash a0 + hashint a1        | hash (Inside(a0,a1)) = 0w197 + ImageInfo.hash a0 + hashint a1
319        | hash (LoadSeq(a0,a1)) = 0w199 + hashty a0 + hashstring a1        | hash (LoadSeq(a0,a1)) = 0w199 + hashty a0 + hashstring a1
320        | hash (LoadImage(a0,a1,a2)) = 0w211 + hashty a0 + hashstring a1 + ImageInfo.hash a2        | hash (LoadImage(a0,a1,a2)) = 0w211 + hashty a0 + hashstring a1 + ImageInfo.hash a2
321        | hash (Input(a0)) = 0w223 + hashinput a0        (*| hash (Input(a0)) = 0w223 + hashinput a0*)
322        | hash (Print(a0)) = 0w227 + hashtys a0        | hash (Print(a0)) = 0w227 + hashtys a0
323    
324      fun toString (IAdd(a0)) = concat["IAdd<", tyToString a0, ">"]  
325        | toString (ISub(a0)) = concat["ISub<", tyToString a0, ">"]      fun intList(ix)=String.concat (List.map (fn(e)=>Int.toString(e)) ix)
326        | toString (IMul(a0)) = concat["IMul<", tyToString a0, ">"]  
327        | toString (IDiv(a0)) = concat["IDiv<", tyToString a0, ">"]      fun toString (IAdd) = concat["IAdd"]
328        | toString (INeg(a0)) = concat["INeg<", tyToString a0, ">"]        | toString (ISub) = concat["ISub"]
329          | toString (IMul) = concat["IMul"]
330          | toString (IDiv) = concat["IDiv"]
331          | toString (INeg) = concat["INeg"]
332        | toString (Abs(a0)) = concat["Abs<", tyToString a0, ">"]        | toString (Abs(a0)) = concat["Abs<", tyToString a0, ">"]
333        | toString (LT(a0)) = concat["LT<", tyToString a0, ">"]        | toString (LT(a0)) = concat["LT<", tyToString a0, ">"]
334        | toString (LTE(a0)) = concat["LTE<", tyToString a0, ">"]        | toString (LTE(a0)) = concat["LTE<", tyToString a0, ">"]
# Line 325  Line 363 
363        | toString (Trunc(a0)) = concat["Trunc<", intToString a0, ">"]        | toString (Trunc(a0)) = concat["Trunc<", intToString a0, ">"]
364        | toString IntToReal = "IntToReal"        | toString IntToReal = "IntToReal"
365        | toString (RealToInt(a0)) = concat["RealToInt<", intToString a0, ">"]        | toString (RealToInt(a0)) = concat["RealToInt<", intToString a0, ">"]
366        | toString (Transform(a0)) = concat["Transform<", Imageinfo.toString a0, ">"]       (* | toString (Transform(a0)) = concat["Transform<", Imageinfo.toString a0, ">"]
367        | toString (Translate(a0)) = concat["Translate<", Imageinfo.toString a0, ">"]        | toString (Translate(a0)) = concat["Translate<", Imageinfo.toString a0, ">"]*)
368        | toString (ImageAddress(a0)) = concat["ImageAddress<", ImageInfo.toString a0, ">"]        | toString (ImageAddress(a0)) = concat["ImageAddress<", ImageInfo.toString a0, ">"]
369        | toString (LoadVoxels(a0,a1)) = concat["LoadVoxels<", ImageInfo.toString a0, ",", intToString a1, ">"]        | toString (LoadVoxels(a0,a1)) = concat["LoadVoxels<", ImageInfo.toString a0, ",", intToString a1, ">"]
370        | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"]        | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"]
371        | toString (LoadSeq(a0,a1)) = concat["LoadSeq<", tyToString a0, ",", stringToString a1, ">"]        | toString (LoadSeq(a0,a1)) = concat["LoadSeq<", tyToString a0, ",", stringToString a1, ">"]
372        | 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, ">"]
373        | toString (Input(a0)) = concat["Input<", inputToString a0, ">"]        (*| toString (Input(a0)) = concat["Input<", inputToString a0, ">"]*)
374            | toString(V(id,ix))=concat["Projection:",Int.toString(id)," at ",(intList ix)," "]
375            | toString(S (id,ix))=concat["Sca:",Int.toString(id)," at ",(intList ix)," "]
376              | toString(C c)=concat["Const: ",Int.toString(c)," "]
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)="Cons"
387            | toString(img (id,ix))=concat["Image:",Int.toString(id)," at ",(intList ix)," "]
388              | toString(krn _)="Krn"
389        | toString (Print(a0)) = concat["Print<", tysToString a0, ">"]        | toString (Print(a0)) = concat["Print<", tysToString a0, ">"]
390    
391    
392    
393    end    end
394    
395  structure LowIL = SSAFn(  structure LowIL = SSAFn(

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

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