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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/mid-ir/mid-ir.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/mid-ir/mid-ir.sml

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

revision 3480, Fri Dec 4 18:30:36 2015 UTC revision 3508, Fri Dec 18 14:19:30 2015 UTC
# Line 44  Line 44 
44      fun maskToString m =      fun maskToString m =
45            String.concat(List.map (fn true => "_" | false => ":") m)            String.concat(List.map (fn true => "_" | false => ":") m)
46    
   (* required helper functions for the input type *)  
     type input = ty Inputs.input  
     val sameinput = Inputs.same  
     val hashinput = Inputs.hash  
     val inputToString = Inputs.toString  
   
47    (* required helper functions for the index control type type *)    (* required helper functions for the index control type type *)
48      type idxctl = IndexCtl.ctl      type idxctl = IndexCtl.ctl
49      val sameidxctl = IndexCtl.same      val sameidxctl = IndexCtl.same
# Line 63  Line 57 
57        | IDiv        | IDiv
58        | IMod        | IMod
59        | INeg        | INeg
       | Abs of ty  
60        | LT of ty        | LT of ty
61        | LTE of ty        | LTE of ty
62        | EQ of ty        | EQ of ty
# Line 71  Line 64 
64        | GT of ty        | GT of ty
65        | GTE of ty        | GTE of ty
66        | Not        | Not
67        | Max        | Abs of ty
68        | Min        | Max of ty
69          | Min of ty
70        | Clamp of ty        | Clamp of ty
71        | Lerp of ty        | Lerp of ty
72        | Normalize of int        | Normalize of int
# Line 89  Line 83 
83        | Append of ty        | Append of ty
84        | Prepend of ty        | Prepend of ty
85        | Concat of ty        | Concat of ty
86          | Range
87        | Length of ty        | Length of ty
88        | Ceiling of int        | Ceiling of int
89        | Floor of int        | Floor of int
# Line 107  Line 102 
102        | ImageDim of ImageInfo.info * int        | ImageDim of ImageInfo.info * int
103        | LoadSeq of ty * string        | LoadSeq of ty * string
104        | LoadImage of ty * string        | LoadImage of ty * string
       | Input of input  
       | InputWithDefault of input  
105        | Print of tys        | Print of tys
106    
107      fun resultArity IAdd = 1      fun resultArity IAdd = 1
# Line 117  Line 110 
110        | resultArity IDiv = 1        | resultArity IDiv = 1
111        | resultArity IMod = 1        | resultArity IMod = 1
112        | resultArity INeg = 1        | resultArity INeg = 1
       | resultArity (Abs _) = 1  
113        | resultArity (LT _) = 1        | resultArity (LT _) = 1
114        | resultArity (LTE _) = 1        | resultArity (LTE _) = 1
115        | resultArity (EQ _) = 1        | resultArity (EQ _) = 1
# Line 125  Line 117 
117        | resultArity (GT _) = 1        | resultArity (GT _) = 1
118        | resultArity (GTE _) = 1        | resultArity (GTE _) = 1
119        | resultArity Not = 1        | resultArity Not = 1
120        | resultArity Max = 1        | resultArity (Abs _) = 1
121        | resultArity Min = 1        | resultArity (Max _) = 1
122          | resultArity (Min _) = 1
123        | resultArity (Clamp _) = 1        | resultArity (Clamp _) = 1
124        | resultArity (Lerp _) = 1        | resultArity (Lerp _) = 1
125        | resultArity (Normalize _) = 1        | resultArity (Normalize _) = 1
# Line 143  Line 136 
136        | resultArity (Append _) = 2        | resultArity (Append _) = 2
137        | resultArity (Prepend _) = 2        | resultArity (Prepend _) = 2
138        | resultArity (Concat _) = 2        | resultArity (Concat _) = 2
139          | resultArity Range = 2
140        | resultArity (Length _) = 1        | resultArity (Length _) = 1
141        | resultArity (Ceiling _) = 1        | resultArity (Ceiling _) = 1
142        | resultArity (Floor _) = 1        | resultArity (Floor _) = 1
# Line 161  Line 155 
155        | resultArity (ImageDim _) = 1        | resultArity (ImageDim _) = 1
156        | resultArity (LoadSeq _) = 1        | resultArity (LoadSeq _) = 1
157        | resultArity (LoadImage _) = 1        | resultArity (LoadImage _) = 1
       | resultArity (Input _) = 0  
       | resultArity (InputWithDefault _) = 0  
158        | resultArity (Print _) = 0        | resultArity (Print _) = 0
159    
160      fun arity IAdd = 2      fun arity IAdd = 2
# Line 171  Line 163 
163        | arity IDiv = 2        | arity IDiv = 2
164        | arity IMod = 2        | arity IMod = 2
165        | arity INeg = 1        | arity INeg = 1
       | arity (Abs _) = 1  
166        | arity (LT _) = 2        | arity (LT _) = 2
167        | arity (LTE _) = 2        | arity (LTE _) = 2
168        | arity (EQ _) = 2        | arity (EQ _) = 2
# Line 179  Line 170 
170        | arity (GT _) = 2        | arity (GT _) = 2
171        | arity (GTE _) = 2        | arity (GTE _) = 2
172        | arity Not = 1        | arity Not = 1
173        | arity Max = 2        | arity (Abs _) = 1
174        | arity Min = 2        | arity (Max _) = 2
175          | arity (Min _) = 2
176        | arity (Clamp _) = 3        | arity (Clamp _) = 3
177        | arity (Lerp _) = 3        | arity (Lerp _) = 3
178        | arity (Normalize _) = 1        | arity (Normalize _) = 1
# Line 197  Line 189 
189        | arity (Append _) = 1        | arity (Append _) = 1
190        | arity (Prepend _) = 1        | arity (Prepend _) = 1
191        | arity (Concat _) = 1        | arity (Concat _) = 1
192          | arity Range = 1
193        | arity (Length _) = 1        | arity (Length _) = 1
194        | arity (Ceiling _) = 1        | arity (Ceiling _) = 1
195        | arity (Floor _) = 1        | arity (Floor _) = 1
# Line 215  Line 208 
208        | arity (ImageDim _) = 1        | arity (ImageDim _) = 1
209        | arity (LoadSeq _) = 0        | arity (LoadSeq _) = 0
210        | arity (LoadImage _) = 0        | arity (LoadImage _) = 0
       | arity (Input _) = 0  
       | arity (InputWithDefault _) = 1  
211        | arity (Print _) = ~1        | arity (Print _) = ~1
212    
213      fun isPure (MkDynamic _) = false      fun isPure (MkDynamic _) = false
214        | isPure (Append _) = false        | isPure (Append _) = false
215        | isPure (Prepend _) = false        | isPure (Prepend _) = false
216        | isPure (Concat _) = false        | isPure (Concat _) = false
       | isPure (Input _) = false  
       | isPure (InputWithDefault _) = false  
217        | isPure (Print _) = false        | isPure (Print _) = false
218        | isPure _ = true        | isPure _ = true
219    
# Line 234  Line 223 
223        | same (IDiv, IDiv) = true        | same (IDiv, IDiv) = true
224        | same (IMod, IMod) = true        | same (IMod, IMod) = true
225        | same (INeg, INeg) = true        | same (INeg, INeg) = true
       | same (Abs(a0), Abs(b0)) = samety(a0, b0)  
226        | same (LT(a0), LT(b0)) = samety(a0, b0)        | same (LT(a0), LT(b0)) = samety(a0, b0)
227        | same (LTE(a0), LTE(b0)) = samety(a0, b0)        | same (LTE(a0), LTE(b0)) = samety(a0, b0)
228        | same (EQ(a0), EQ(b0)) = samety(a0, b0)        | same (EQ(a0), EQ(b0)) = samety(a0, b0)
# Line 242  Line 230 
230        | same (GT(a0), GT(b0)) = samety(a0, b0)        | same (GT(a0), GT(b0)) = samety(a0, b0)
231        | same (GTE(a0), GTE(b0)) = samety(a0, b0)        | same (GTE(a0), GTE(b0)) = samety(a0, b0)
232        | same (Not, Not) = true        | same (Not, Not) = true
233        | same (Max, Max) = true        | same (Abs(a0), Abs(b0)) = samety(a0, b0)
234        | same (Min, Min) = true        | same (Max(a0), Max(b0)) = samety(a0, b0)
235          | same (Min(a0), Min(b0)) = samety(a0, b0)
236        | same (Clamp(a0), Clamp(b0)) = samety(a0, b0)        | same (Clamp(a0), Clamp(b0)) = samety(a0, b0)
237        | same (Lerp(a0), Lerp(b0)) = samety(a0, b0)        | same (Lerp(a0), Lerp(b0)) = samety(a0, b0)
238        | same (Normalize(a0), Normalize(b0)) = sameint(a0, b0)        | same (Normalize(a0), Normalize(b0)) = sameint(a0, b0)
# Line 260  Line 249 
249        | same (Append(a0), Append(b0)) = samety(a0, b0)        | same (Append(a0), Append(b0)) = samety(a0, b0)
250        | same (Prepend(a0), Prepend(b0)) = samety(a0, b0)        | same (Prepend(a0), Prepend(b0)) = samety(a0, b0)
251        | same (Concat(a0), Concat(b0)) = samety(a0, b0)        | same (Concat(a0), Concat(b0)) = samety(a0, b0)
252          | same (Range, Range) = true
253        | same (Length(a0), Length(b0)) = samety(a0, b0)        | same (Length(a0), Length(b0)) = samety(a0, b0)
254        | same (Ceiling(a0), Ceiling(b0)) = sameint(a0, b0)        | same (Ceiling(a0), Ceiling(b0)) = sameint(a0, b0)
255        | same (Floor(a0), Floor(b0)) = sameint(a0, b0)        | same (Floor(a0), Floor(b0)) = sameint(a0, b0)
# Line 278  Line 268 
268        | same (ImageDim(a0,a1), ImageDim(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1)        | same (ImageDim(a0,a1), ImageDim(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), LoadImage(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)        | same (LoadImage(a0,a1), LoadImage(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
       | same (Input(a0), Input(b0)) = sameinput(a0, b0)  
       | same (InputWithDefault(a0), InputWithDefault(b0)) = sameinput(a0, b0)  
271        | same (Print(a0), Print(b0)) = sametys(a0, b0)        | same (Print(a0), Print(b0)) = sametys(a0, b0)
272        | same _ = false        | same _ = false
273    
# Line 289  Line 277 
277        | hash IDiv = 0w11        | hash IDiv = 0w11
278        | hash IMod = 0w13        | hash IMod = 0w13
279        | hash INeg = 0w17        | hash INeg = 0w17
280        | hash (Abs(a0)) = 0w19 + hashty a0        | hash (LT(a0)) = 0w19 + hashty a0
281        | hash (LT(a0)) = 0w23 + hashty a0        | hash (LTE(a0)) = 0w23 + hashty a0
282        | hash (LTE(a0)) = 0w29 + hashty a0        | hash (EQ(a0)) = 0w29 + hashty a0
283        | hash (EQ(a0)) = 0w31 + hashty a0        | hash (NEQ(a0)) = 0w31 + hashty a0
284        | hash (NEQ(a0)) = 0w37 + hashty a0        | hash (GT(a0)) = 0w37 + hashty a0
285        | hash (GT(a0)) = 0w41 + hashty a0        | hash (GTE(a0)) = 0w41 + hashty a0
286        | hash (GTE(a0)) = 0w43 + hashty a0        | hash Not = 0w43
287        | hash Not = 0w47        | hash (Abs(a0)) = 0w47 + hashty a0
288        | hash Max = 0w53        | hash (Max(a0)) = 0w53 + hashty a0
289        | hash Min = 0w59        | hash (Min(a0)) = 0w59 + hashty a0
290        | hash (Clamp(a0)) = 0w61 + hashty a0        | hash (Clamp(a0)) = 0w61 + hashty a0
291        | hash (Lerp(a0)) = 0w67 + hashty a0        | hash (Lerp(a0)) = 0w67 + hashty a0
292        | hash (Normalize(a0)) = 0w71 + hashint a0        | hash (Normalize(a0)) = 0w71 + hashint a0
# Line 315  Line 303 
303        | hash (Append(a0)) = 0w127 + hashty a0        | hash (Append(a0)) = 0w127 + hashty a0
304        | hash (Prepend(a0)) = 0w131 + hashty a0        | hash (Prepend(a0)) = 0w131 + hashty a0
305        | hash (Concat(a0)) = 0w137 + hashty a0        | hash (Concat(a0)) = 0w137 + hashty a0
306        | hash (Length(a0)) = 0w139 + hashty a0        | hash Range = 0w139
307        | hash (Ceiling(a0)) = 0w149 + hashint a0        | hash (Length(a0)) = 0w149 + hashty a0
308        | hash (Floor(a0)) = 0w151 + hashint a0        | hash (Ceiling(a0)) = 0w151 + hashint a0
309        | hash (Round(a0)) = 0w157 + hashint a0        | hash (Floor(a0)) = 0w157 + hashint a0
310        | hash (Trunc(a0)) = 0w163 + hashint a0        | hash (Round(a0)) = 0w163 + hashint a0
311        | hash IntToReal = 0w167        | hash (Trunc(a0)) = 0w167 + hashint a0
312        | hash (RealToInt(a0)) = 0w173 + hashint a0        | hash IntToReal = 0w173
313        | hash (Kernel(a0,a1)) = 0w179 + Kernel.hash a0 + hashint a1        | hash (RealToInt(a0)) = 0w179 + hashint a0
314        | hash (Transform(a0)) = 0w181 + ImageInfo.hash a0        | hash (Kernel(a0,a1)) = 0w181 + Kernel.hash a0 + hashint a1
315        | hash (Translate(a0)) = 0w191 + ImageInfo.hash a0        | hash (Transform(a0)) = 0w191 + ImageInfo.hash a0
316        | hash (EvalKernel(a0,a1,a2)) = 0w193 + hashint a0 + Kernel.hash a1 + hashint a2        | hash (Translate(a0)) = 0w193 + ImageInfo.hash a0
317        | hash (VoxelAddress(a0,a1)) = 0w197 + ImageInfo.hash a0 + hashint a1        | hash (EvalKernel(a0,a1,a2)) = 0w197 + hashint a0 + Kernel.hash a1 + hashint a2
318        | hash (VoxelAddressWithCtl(a0,a1,a2)) = 0w199 + ImageInfo.hash a0 + hashint a1 + hashidxctl a2        | hash (VoxelAddress(a0,a1)) = 0w199 + ImageInfo.hash a0 + hashint a1
319        | hash (LoadVoxels(a0,a1)) = 0w211 + ImageInfo.hash a0 + hashint a1        | hash (VoxelAddressWithCtl(a0,a1,a2)) = 0w211 + ImageInfo.hash a0 + hashint a1 + hashidxctl a2
320        | hash (Inside(a0,a1)) = 0w223 + ImageInfo.hash a0 + hashint a1        | hash (LoadVoxels(a0,a1)) = 0w223 + ImageInfo.hash a0 + hashint a1
321        | hash (ImageDim(a0,a1)) = 0w227 + ImageInfo.hash a0 + hashint a1        | hash (Inside(a0,a1)) = 0w227 + ImageInfo.hash a0 + hashint a1
322        | hash (LoadSeq(a0,a1)) = 0w229 + hashty a0 + hashstring a1        | hash (ImageDim(a0,a1)) = 0w229 + ImageInfo.hash a0 + hashint a1
323        | hash (LoadImage(a0,a1)) = 0w233 + hashty a0 + hashstring a1        | hash (LoadSeq(a0,a1)) = 0w233 + hashty a0 + hashstring a1
324        | hash (Input(a0)) = 0w239 + hashinput a0        | hash (LoadImage(a0,a1)) = 0w239 + hashty a0 + hashstring a1
325        | hash (InputWithDefault(a0)) = 0w241 + hashinput a0        | hash (Print(a0)) = 0w241 + hashtys a0
       | hash (Print(a0)) = 0w251 + hashtys a0  
326    
327      fun toString IAdd = "IAdd"      fun toString IAdd = "IAdd"
328        | toString ISub = "ISub"        | toString ISub = "ISub"
# Line 343  Line 330 
330        | toString IDiv = "IDiv"        | toString IDiv = "IDiv"
331        | toString IMod = "IMod"        | toString IMod = "IMod"
332        | toString INeg = "INeg"        | toString INeg = "INeg"
       | 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, ">"]
335        | toString (EQ(a0)) = concat["EQ<", tyToString a0, ">"]        | toString (EQ(a0)) = concat["EQ<", tyToString a0, ">"]
# Line 351  Line 337 
337        | toString (GT(a0)) = concat["GT<", tyToString a0, ">"]        | toString (GT(a0)) = concat["GT<", tyToString a0, ">"]
338        | toString (GTE(a0)) = concat["GTE<", tyToString a0, ">"]        | toString (GTE(a0)) = concat["GTE<", tyToString a0, ">"]
339        | toString Not = "Not"        | toString Not = "Not"
340        | toString Max = "Max"        | toString (Abs(a0)) = concat["Abs<", tyToString a0, ">"]
341        | toString Min = "Min"        | toString (Max(a0)) = concat["Max<", tyToString a0, ">"]
342          | toString (Min(a0)) = concat["Min<", tyToString a0, ">"]
343        | toString (Clamp(a0)) = concat["Clamp<", tyToString a0, ">"]        | toString (Clamp(a0)) = concat["Clamp<", tyToString a0, ">"]
344        | toString (Lerp(a0)) = concat["Lerp<", tyToString a0, ">"]        | toString (Lerp(a0)) = concat["Lerp<", tyToString a0, ">"]
345        | toString (Normalize(a0)) = concat["Normalize<", intToString a0, ">"]        | toString (Normalize(a0)) = concat["Normalize<", intToString a0, ">"]
# Line 369  Line 356 
356        | toString (Append(a0)) = concat["Append<", tyToString a0, ">"]        | toString (Append(a0)) = concat["Append<", tyToString a0, ">"]
357        | toString (Prepend(a0)) = concat["Prepend<", tyToString a0, ">"]        | toString (Prepend(a0)) = concat["Prepend<", tyToString a0, ">"]
358        | toString (Concat(a0)) = concat["Concat<", tyToString a0, ">"]        | toString (Concat(a0)) = concat["Concat<", tyToString a0, ">"]
359          | toString Range = "Range"
360        | toString (Length(a0)) = concat["Length<", tyToString a0, ">"]        | toString (Length(a0)) = concat["Length<", tyToString a0, ">"]
361        | toString (Ceiling(a0)) = concat["Ceiling<", intToString a0, ">"]        | toString (Ceiling(a0)) = concat["Ceiling<", intToString a0, ">"]
362        | toString (Floor(a0)) = concat["Floor<", intToString a0, ">"]        | toString (Floor(a0)) = concat["Floor<", intToString a0, ">"]
# Line 387  Line 375 
375        | toString (ImageDim(a0,a1)) = concat["ImageDim<", ImageInfo.toString a0, ",", intToString a1, ">"]        | toString (ImageDim(a0,a1)) = concat["ImageDim<", ImageInfo.toString a0, ",", intToString a1, ">"]
376        | toString (LoadSeq(a0,a1)) = concat["LoadSeq<", tyToString a0, ",", stringToString a1, ">"]        | toString (LoadSeq(a0,a1)) = concat["LoadSeq<", tyToString a0, ",", stringToString a1, ">"]
377        | toString (LoadImage(a0,a1)) = concat["LoadImage<", tyToString a0, ",", stringToString a1, ">"]        | toString (LoadImage(a0,a1)) = concat["LoadImage<", tyToString a0, ",", stringToString a1, ">"]
       | toString (Input(a0)) = concat["Input<", inputToString a0, ">"]  
       | toString (InputWithDefault(a0)) = concat["InputWithDefault<", inputToString a0, ">"]  
378        | toString (Print(a0)) = concat["Print<", tysToString a0, ">"]        | toString (Print(a0)) = concat["Print<", tysToString a0, ">"]
379    
380    end    end
381    
382  structure MidIR = SSAFn(  structure MidIR = SSAFn(
383    val ilName = "mid-ir"    val irName = "mid-ir"
384    structure Ty = MidTypes    structure Ty = MidTypes
385    structure Op = MidOps)    structure Op = MidOps)
386    

Legend:
Removed from v.3480  
changed lines
  Added in v.3508

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