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

SCM Repository

[diderot] Diff of /trunk/src/compiler/mid-il/mid-il.sml
ViewVC logotype

Diff of /trunk/src/compiler/mid-il/mid-il.sml

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

revision 349, Fri Sep 24 00:24:20 2010 UTC revision 450, Thu Oct 21 15:58:26 2010 UTC
# Line 1  Line 1 
1  (* mid-il.sml  (* mid-il.sml
2   *   *
3   * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)   * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4   * All rights reserved.   * All rights reserved.
5   *   *
6   * Middle-level version of the Diderot IL.   * Middle-level version of the Diderot IL.
# Line 11  Line 11 
11  structure MidOps =  structure MidOps =
12    struct    struct
13    
14      datatype ty = BoolTy | StringTy | IntTy | VecTy of int      type ty = MidILTypes.ty
15    
16      val realTy = VecTy 0      val samety = MidILTypes.same
17        val hashty = MidILTypes.hash
18      fun samety (ty1 : ty, ty2) = (ty1 = ty2)      val tyToString = MidILTypes.toString
     fun hashty BoolTy = 0w1  
       | hashty StringTy = 0w2  
       | hashty IntTy = 0w3  
       | hashty (VecTy d) = Word.fromInt d + 0w4  
     fun tyToString BoolTy = "bool"  
       | tyToString StringTy = "string"  
       | tyToString IntTy = "int"  
       | tyToString (VecTy 0) = "real"  
       | tyToString (VecTy d) = "vec" ^ Int.toString d  
19    
20      fun sameint (i1 : int, i2) = (i1 = i2)      fun sameint (i1 : int, i2) = (i1 = i2)
21      fun hashint i = Word.fromInt i      fun hashint i = Word.fromInt i
# Line 54  Line 45 
45        | Pow        | Pow
46        | Dot of int        | Dot of int
47        | Cross        | Cross
48        | Select of int * int        | Select of ty * int
49        | Norm of int        | Norm of int
50        | Scale of int        | Scale of int
51        | InvScale of int        | InvScale of int
# Line 69  Line 60 
60        | FloorToInt of int        | FloorToInt of int
61        | VoxelAddress of ImageInfo.info        | VoxelAddress of ImageInfo.info
62        | LoadVoxels of RawTypes.ty * int        | LoadVoxels of RawTypes.ty * int
63        | Transform of ImageInfo.info        | PosToImgSpace of ImageInfo.info
64          | GradToWorldSpace of ImageInfo.info
65        | EvalKernel of int * Kernel.kernel * int        | EvalKernel of int * Kernel.kernel * int
66        | LoadImage of ImageInfo.info        | LoadImage of ImageInfo.info
67        | Inside of ImageInfo.info        | Inside of ImageInfo.info
68        | Input of string        | Input of ty * string
69        | InputWithDefault of string        | InputWithDefault of ty * string
70    
71      fun arity (Add _) = 2      fun arity (Add _) = 2
72        | arity (Sub _) = 2        | arity (Sub _) = 2
# Line 110  Line 102 
102        | arity (FloorToInt _) = 1        | arity (FloorToInt _) = 1
103        | arity (VoxelAddress _) = ~1        | arity (VoxelAddress _) = ~1
104        | arity (LoadVoxels _) = 1        | arity (LoadVoxels _) = 1
105        | arity (Transform _) = 1        | arity (PosToImgSpace _) = 1
106          | arity (GradToWorldSpace _) = 1
107        | arity (EvalKernel _) = 1        | arity (EvalKernel _) = 1
108        | arity (LoadImage _) = 0        | arity (LoadImage _) = 0
109        | arity (Inside _) = 1        | arity (Inside _) = 1
# Line 136  Line 129 
129        | same (Pow, Pow) = true        | same (Pow, Pow) = true
130        | same (Dot(a0), Dot(b0)) = sameint(a0, b0)        | same (Dot(a0), Dot(b0)) = sameint(a0, b0)
131        | same (Cross, Cross) = true        | same (Cross, Cross) = true
132        | same (Select(a0,a1), Select(b0,b1)) = sameint(a0, b0) andalso sameint(a1, b1)        | same (Select(a0,a1), Select(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1)
133        | same (Norm(a0), Norm(b0)) = sameint(a0, b0)        | same (Norm(a0), Norm(b0)) = sameint(a0, b0)
134        | same (Scale(a0), Scale(b0)) = sameint(a0, b0)        | same (Scale(a0), Scale(b0)) = sameint(a0, b0)
135        | same (InvScale(a0), InvScale(b0)) = sameint(a0, b0)        | same (InvScale(a0), InvScale(b0)) = sameint(a0, b0)
# Line 151  Line 144 
144        | same (FloorToInt(a0), FloorToInt(b0)) = sameint(a0, b0)        | same (FloorToInt(a0), FloorToInt(b0)) = sameint(a0, b0)
145        | same (VoxelAddress(a0), VoxelAddress(b0)) = ImageInfo.same(a0, b0)        | same (VoxelAddress(a0), VoxelAddress(b0)) = ImageInfo.same(a0, b0)
146        | same (LoadVoxels(a0,a1), LoadVoxels(b0,b1)) = RawTypes.same(a0, b0) andalso sameint(a1, b1)        | same (LoadVoxels(a0,a1), LoadVoxels(b0,b1)) = RawTypes.same(a0, b0) andalso sameint(a1, b1)
147        | same (Transform(a0), Transform(b0)) = ImageInfo.same(a0, b0)        | same (PosToImgSpace(a0), PosToImgSpace(b0)) = ImageInfo.same(a0, b0)
148          | same (GradToWorldSpace(a0), GradToWorldSpace(b0)) = ImageInfo.same(a0, b0)
149        | 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)
150        | same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0)        | same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0)
151        | same (Inside(a0), Inside(b0)) = ImageInfo.same(a0, b0)        | same (Inside(a0), Inside(b0)) = ImageInfo.same(a0, b0)
152        | same (Input(a0), Input(b0)) = samestring(a0, b0)        | same (Input(a0,a1), Input(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
153        | same (InputWithDefault(a0), InputWithDefault(b0)) = samestring(a0, b0)        | same (InputWithDefault(a0,a1), InputWithDefault(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
154        | same _ = false        | same _ = false
155    
156      fun hash (Add(a0)) = 0w3 + hashty a0      fun hash (Add(a0)) = 0w3 + hashty a0
# Line 178  Line 172 
172        | hash Pow = 0w61        | hash Pow = 0w61
173        | hash (Dot(a0)) = 0w67 + hashint a0        | hash (Dot(a0)) = 0w67 + hashint a0
174        | hash Cross = 0w71        | hash Cross = 0w71
175        | hash (Select(a0,a1)) = 0w73 + hashint a0 + hashint a1        | hash (Select(a0,a1)) = 0w73 + hashty a0 + hashint a1
176        | hash (Norm(a0)) = 0w79 + hashint a0        | hash (Norm(a0)) = 0w79 + hashint a0
177        | hash (Scale(a0)) = 0w83 + hashint a0        | hash (Scale(a0)) = 0w83 + hashint a0
178        | hash (InvScale(a0)) = 0w89 + hashint a0        | hash (InvScale(a0)) = 0w89 + hashint a0
# Line 193  Line 187 
187        | hash (FloorToInt(a0)) = 0w137 + hashint a0        | hash (FloorToInt(a0)) = 0w137 + hashint a0
188        | hash (VoxelAddress(a0)) = 0w139 + ImageInfo.hash a0        | hash (VoxelAddress(a0)) = 0w139 + ImageInfo.hash a0
189        | hash (LoadVoxels(a0,a1)) = 0w149 + RawTypes.hash a0 + hashint a1        | hash (LoadVoxels(a0,a1)) = 0w149 + RawTypes.hash a0 + hashint a1
190        | hash (Transform(a0)) = 0w151 + ImageInfo.hash a0        | hash (PosToImgSpace(a0)) = 0w151 + ImageInfo.hash a0
191        | hash (EvalKernel(a0,a1,a2)) = 0w157 + hashint a0 + Kernel.hash a1 + hashint a2        | hash (GradToWorldSpace(a0)) = 0w157 + ImageInfo.hash a0
192        | hash (LoadImage(a0)) = 0w163 + ImageInfo.hash a0        | hash (EvalKernel(a0,a1,a2)) = 0w163 + hashint a0 + Kernel.hash a1 + hashint a2
193        | hash (Inside(a0)) = 0w167 + ImageInfo.hash a0        | hash (LoadImage(a0)) = 0w167 + ImageInfo.hash a0
194        | hash (Input(a0)) = 0w173 + hashstring a0        | hash (Inside(a0)) = 0w173 + ImageInfo.hash a0
195        | hash (InputWithDefault(a0)) = 0w179 + hashstring a0        | hash (Input(a0,a1)) = 0w179 + hashty a0 + hashstring a1
196          | hash (InputWithDefault(a0,a1)) = 0w181 + hashty a0 + hashstring a1
197    
198      fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]      fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]
199        | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]        | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]
# Line 219  Line 214 
214        | toString Pow = "Pow"        | toString Pow = "Pow"
215        | toString (Dot(a0)) = concat["Dot<", intToString a0, ">"]        | toString (Dot(a0)) = concat["Dot<", intToString a0, ">"]
216        | toString Cross = "Cross"        | toString Cross = "Cross"
217        | toString (Select(a0,a1)) = concat["Select<", intToString a0, ",", intToString a1, ">"]        | toString (Select(a0,a1)) = concat["Select<", tyToString a0, ",", intToString a1, ">"]
218        | toString (Norm(a0)) = concat["Norm<", intToString a0, ">"]        | toString (Norm(a0)) = concat["Norm<", intToString a0, ">"]
219        | toString (Scale(a0)) = concat["Scale<", intToString a0, ">"]        | toString (Scale(a0)) = concat["Scale<", intToString a0, ">"]
220        | toString (InvScale(a0)) = concat["InvScale<", intToString a0, ">"]        | toString (InvScale(a0)) = concat["InvScale<", intToString a0, ">"]
# Line 234  Line 229 
229        | toString (FloorToInt(a0)) = concat["FloorToInt<", intToString a0, ">"]        | toString (FloorToInt(a0)) = concat["FloorToInt<", intToString a0, ">"]
230        | toString (VoxelAddress(a0)) = concat["VoxelAddress<", ImageInfo.toString a0, ">"]        | toString (VoxelAddress(a0)) = concat["VoxelAddress<", ImageInfo.toString a0, ">"]
231        | toString (LoadVoxels(a0,a1)) = concat["LoadVoxels<", RawTypes.toString a0, ",", intToString a1, ">"]        | toString (LoadVoxels(a0,a1)) = concat["LoadVoxels<", RawTypes.toString a0, ",", intToString a1, ">"]
232        | toString (Transform(a0)) = concat["Transform<", ImageInfo.toString a0, ">"]        | toString (PosToImgSpace(a0)) = concat["PosToImgSpace<", ImageInfo.toString a0, ">"]
233          | toString (GradToWorldSpace(a0)) = concat["GradToWorldSpace<", ImageInfo.toString a0, ">"]
234        | 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, ">"]
235        | toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"]        | toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"]
236        | toString (Inside(a0)) = concat["Inside<", ImageInfo.toString a0, ">"]        | toString (Inside(a0)) = concat["Inside<", ImageInfo.toString a0, ">"]
237        | toString (Input(a0)) = concat["Input<", stringToString a0, ">"]        | toString (Input(a0,a1)) = concat["Input<", tyToString a0, ",", stringToString a1, ">"]
238        | toString (InputWithDefault(a0)) = concat["InputWithDefault<", stringToString a0, ">"]        | toString (InputWithDefault(a0,a1)) = concat["InputWithDefault<", tyToString a0, ",", stringToString a1, ">"]
239    
240    end    end
241    
242  structure MidIL = SSAFn(MidOps)  structure MidIL = SSAFn(
243      structure Ty = MidILTypes
244      structure Op = MidOps)

Legend:
Removed from v.349  
changed lines
  Added in v.450

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