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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1232 - (view) (download)

1 : jhr 287 (* mid-il.sml
2 :     *
3 : jhr 435 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 : jhr 287 * All rights reserved.
5 :     *
6 :     * Middle-level version of the Diderot IL.
7 :     *
8 :     * Note: this file is generated from gen/mid-il.spec and gen/mid-il.in.
9 :     *)
10 :    
11 :     structure MidOps =
12 :     struct
13 :    
14 : jhr 391 type ty = MidILTypes.ty
15 : jhr 287
16 : jhr 391 val samety = MidILTypes.same
17 :     val hashty = MidILTypes.hash
18 :     val tyToString = MidILTypes.toString
19 : jhr 328
20 : jhr 1116 (* required helper functions for the int type *)
21 : jhr 332 fun sameint (i1 : int, i2) = (i1 = i2)
22 :     fun hashint i = Word.fromInt i
23 :     fun intToString i = Int.toString i
24 :    
25 : jhr 1116 (* required helper functions for the string type *)
26 : jhr 287 fun samestring (s1 : string, s2) = (s1 = s2)
27 :     val hashstring = HashString.hashString
28 :     fun stringToString s = String.concat["\"", s, "\""]
29 :    
30 :     datatype rator
31 :     = Add of ty
32 :     | Sub of ty
33 :     | Mul of ty
34 :     | Div of ty
35 :     | Neg of ty
36 : jhr 1116 | Abs of ty
37 : jhr 287 | LT of ty
38 :     | LTE of ty
39 :     | EQ of ty
40 :     | NEQ of ty
41 :     | GT of ty
42 :     | GTE of ty
43 : jhr 333 | Not
44 :     | Max
45 :     | Min
46 : jhr 1116 | Lerp of ty
47 : jhr 349 | Dot of int
48 : jhr 1116 | MulVecMat of int * int
49 :     | MulMatVec of int * int
50 :     | MulMatMat of int * int * int
51 : jhr 287 | Cross
52 : jhr 420 | Select of ty * int
53 : jhr 1116 | Norm of ty
54 :     | Normalize of int
55 :     | Scale of ty
56 : jhr 287 | CL
57 :     | PrincipleEvec of ty
58 : jhr 1116 | Identity of int
59 :     | Zero of ty
60 :     | Trace of int
61 : jhr 287 | Subscript of ty
62 : jhr 1116 | Ceiling of int
63 : jhr 333 | Floor of int
64 : jhr 1116 | Round of int
65 :     | Trunc of int
66 : jhr 287 | IntToReal
67 : jhr 1116 | RealToInt of int
68 :     | VoxelAddress of ImageInfo.info * int
69 :     | LoadVoxels of ImageInfo.info * int
70 : jhr 450 | PosToImgSpace of ImageInfo.info
71 : jhr 1116 | TensorToWorldSpace of ImageInfo.info * ty
72 : jhr 328 | EvalKernel of int * Kernel.kernel * int
73 : jhr 287 | LoadImage of ImageInfo.info
74 : jhr 1116 | Inside of ImageInfo.info * int
75 : jhr 420 | Input of ty * string
76 :     | InputWithDefault of ty * string
77 : jhr 287
78 :     fun arity (Add _) = 2
79 :     | arity (Sub _) = 2
80 :     | arity (Mul _) = 2
81 :     | arity (Div _) = 2
82 :     | arity (Neg _) = 1
83 : jhr 1116 | arity (Abs _) = 1
84 : jhr 287 | arity (LT _) = 2
85 :     | arity (LTE _) = 2
86 :     | arity (EQ _) = 2
87 :     | arity (NEQ _) = 2
88 :     | arity (GT _) = 2
89 :     | arity (GTE _) = 2
90 : jhr 333 | arity Not = 1
91 :     | arity Max = 2
92 :     | arity Min = 2
93 : jhr 1116 | arity (Lerp _) = 3
94 : jhr 287 | arity (Dot _) = 2
95 : jhr 1116 | arity (MulVecMat _) = 2
96 :     | arity (MulMatVec _) = 2
97 :     | arity (MulMatMat _) = 2
98 : jhr 287 | arity Cross = 2
99 :     | arity (Select _) = 1
100 :     | arity (Norm _) = 1
101 : jhr 1116 | arity (Normalize _) = 1
102 : jhr 287 | arity (Scale _) = 2
103 :     | arity CL = 1
104 :     | arity (PrincipleEvec _) = 2
105 : jhr 1116 | arity (Identity _) = 0
106 :     | arity (Zero _) = 0
107 :     | arity (Trace _) = 1
108 : jhr 287 | arity (Subscript _) = 2
109 : jhr 1116 | arity (Ceiling _) = 1
110 : jhr 333 | arity (Floor _) = 1
111 : jhr 1116 | arity (Round _) = 1
112 :     | arity (Trunc _) = 1
113 : jhr 287 | arity IntToReal = 1
114 : jhr 1116 | arity (RealToInt _) = 1
115 : jhr 287 | arity (VoxelAddress _) = ~1
116 :     | arity (LoadVoxels _) = 1
117 : jhr 1116 | arity (PosToImgSpace _) = 2
118 :     | arity (TensorToWorldSpace _) = 2
119 : jhr 328 | arity (EvalKernel _) = 1
120 : jhr 1116 | arity (LoadImage _) = 1
121 :     | arity (Inside _) = 2
122 : jhr 287 | arity (Input _) = 0
123 :     | arity (InputWithDefault _) = 1
124 :    
125 :     fun same (Add(a0), Add(b0)) = samety(a0, b0)
126 :     | same (Sub(a0), Sub(b0)) = samety(a0, b0)
127 :     | same (Mul(a0), Mul(b0)) = samety(a0, b0)
128 :     | same (Div(a0), Div(b0)) = samety(a0, b0)
129 :     | same (Neg(a0), Neg(b0)) = samety(a0, b0)
130 : jhr 1116 | same (Abs(a0), Abs(b0)) = samety(a0, b0)
131 : jhr 287 | same (LT(a0), LT(b0)) = samety(a0, b0)
132 :     | same (LTE(a0), LTE(b0)) = samety(a0, b0)
133 :     | same (EQ(a0), EQ(b0)) = samety(a0, b0)
134 :     | same (NEQ(a0), NEQ(b0)) = samety(a0, b0)
135 :     | same (GT(a0), GT(b0)) = samety(a0, b0)
136 :     | same (GTE(a0), GTE(b0)) = samety(a0, b0)
137 : jhr 333 | same (Not, Not) = true
138 :     | same (Max, Max) = true
139 :     | same (Min, Min) = true
140 : jhr 1116 | same (Lerp(a0), Lerp(b0)) = samety(a0, b0)
141 : jhr 349 | same (Dot(a0), Dot(b0)) = sameint(a0, b0)
142 : jhr 1116 | same (MulVecMat(a0,a1), MulVecMat(b0,b1)) = sameint(a0, b0) andalso sameint(a1, b1)
143 :     | same (MulMatVec(a0,a1), MulMatVec(b0,b1)) = sameint(a0, b0) andalso sameint(a1, b1)
144 :     | same (MulMatMat(a0,a1,a2), MulMatMat(b0,b1,b2)) = sameint(a0, b0) andalso sameint(a1, b1) andalso sameint(a2, b2)
145 : jhr 287 | same (Cross, Cross) = true
146 : jhr 420 | same (Select(a0,a1), Select(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1)
147 : jhr 1116 | same (Norm(a0), Norm(b0)) = samety(a0, b0)
148 :     | same (Normalize(a0), Normalize(b0)) = sameint(a0, b0)
149 :     | same (Scale(a0), Scale(b0)) = samety(a0, b0)
150 : jhr 287 | same (CL, CL) = true
151 :     | same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0)
152 : jhr 1116 | same (Identity(a0), Identity(b0)) = sameint(a0, b0)
153 :     | same (Zero(a0), Zero(b0)) = samety(a0, b0)
154 :     | same (Trace(a0), Trace(b0)) = sameint(a0, b0)
155 : jhr 287 | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)
156 : jhr 1116 | same (Ceiling(a0), Ceiling(b0)) = sameint(a0, b0)
157 : jhr 333 | same (Floor(a0), Floor(b0)) = sameint(a0, b0)
158 : jhr 1116 | same (Round(a0), Round(b0)) = sameint(a0, b0)
159 :     | same (Trunc(a0), Trunc(b0)) = sameint(a0, b0)
160 : jhr 287 | same (IntToReal, IntToReal) = true
161 : jhr 1116 | same (RealToInt(a0), RealToInt(b0)) = sameint(a0, b0)
162 :     | same (VoxelAddress(a0,a1), VoxelAddress(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1)
163 :     | same (LoadVoxels(a0,a1), LoadVoxels(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1)
164 : jhr 450 | same (PosToImgSpace(a0), PosToImgSpace(b0)) = ImageInfo.same(a0, b0)
165 : jhr 1116 | same (TensorToWorldSpace(a0,a1), TensorToWorldSpace(b0,b1)) = ImageInfo.same(a0, b0) andalso samety(a1, b1)
166 : jhr 328 | same (EvalKernel(a0,a1,a2), EvalKernel(b0,b1,b2)) = sameint(a0, b0) andalso Kernel.same(a1, b1) andalso sameint(a2, b2)
167 : jhr 287 | same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0)
168 : jhr 1116 | same (Inside(a0,a1), Inside(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1)
169 : jhr 420 | same (Input(a0,a1), Input(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
170 :     | same (InputWithDefault(a0,a1), InputWithDefault(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
171 : jhr 287 | same _ = false
172 :    
173 :     fun hash (Add(a0)) = 0w3 + hashty a0
174 :     | hash (Sub(a0)) = 0w5 + hashty a0
175 :     | hash (Mul(a0)) = 0w7 + hashty a0
176 :     | hash (Div(a0)) = 0w11 + hashty a0
177 :     | hash (Neg(a0)) = 0w13 + hashty a0
178 : jhr 1116 | hash (Abs(a0)) = 0w17 + hashty a0
179 :     | hash (LT(a0)) = 0w19 + hashty a0
180 :     | hash (LTE(a0)) = 0w23 + hashty a0
181 :     | hash (EQ(a0)) = 0w29 + hashty a0
182 :     | hash (NEQ(a0)) = 0w31 + hashty a0
183 :     | hash (GT(a0)) = 0w37 + hashty a0
184 :     | hash (GTE(a0)) = 0w41 + hashty a0
185 :     | hash Not = 0w43
186 :     | hash Max = 0w47
187 :     | hash Min = 0w53
188 :     | hash (Lerp(a0)) = 0w59 + hashty a0
189 :     | hash (Dot(a0)) = 0w61 + hashint a0
190 :     | hash (MulVecMat(a0,a1)) = 0w67 + hashint a0 + hashint a1
191 :     | hash (MulMatVec(a0,a1)) = 0w71 + hashint a0 + hashint a1
192 :     | hash (MulMatMat(a0,a1,a2)) = 0w73 + hashint a0 + hashint a1 + hashint a2
193 :     | hash Cross = 0w79
194 :     | hash (Select(a0,a1)) = 0w83 + hashty a0 + hashint a1
195 :     | hash (Norm(a0)) = 0w89 + hashty a0
196 :     | hash (Normalize(a0)) = 0w97 + hashint a0
197 :     | hash (Scale(a0)) = 0w101 + hashty a0
198 :     | hash CL = 0w103
199 :     | hash (PrincipleEvec(a0)) = 0w107 + hashty a0
200 :     | hash (Identity(a0)) = 0w109 + hashint a0
201 :     | hash (Zero(a0)) = 0w113 + hashty a0
202 :     | hash (Trace(a0)) = 0w127 + hashint a0
203 :     | hash (Subscript(a0)) = 0w131 + hashty a0
204 :     | hash (Ceiling(a0)) = 0w137 + hashint a0
205 :     | hash (Floor(a0)) = 0w139 + hashint a0
206 :     | hash (Round(a0)) = 0w149 + hashint a0
207 :     | hash (Trunc(a0)) = 0w151 + hashint a0
208 :     | hash IntToReal = 0w157
209 :     | hash (RealToInt(a0)) = 0w163 + hashint a0
210 :     | hash (VoxelAddress(a0,a1)) = 0w167 + ImageInfo.hash a0 + hashint a1
211 :     | hash (LoadVoxels(a0,a1)) = 0w173 + ImageInfo.hash a0 + hashint a1
212 :     | hash (PosToImgSpace(a0)) = 0w179 + ImageInfo.hash a0
213 :     | hash (TensorToWorldSpace(a0,a1)) = 0w181 + ImageInfo.hash a0 + hashty a1
214 :     | hash (EvalKernel(a0,a1,a2)) = 0w191 + hashint a0 + Kernel.hash a1 + hashint a2
215 :     | hash (LoadImage(a0)) = 0w193 + ImageInfo.hash a0
216 :     | hash (Inside(a0,a1)) = 0w197 + ImageInfo.hash a0 + hashint a1
217 :     | hash (Input(a0,a1)) = 0w199 + hashty a0 + hashstring a1
218 :     | hash (InputWithDefault(a0,a1)) = 0w211 + hashty a0 + hashstring a1
219 : jhr 287
220 :     fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]
221 :     | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]
222 :     | toString (Mul(a0)) = concat["Mul<", tyToString a0, ">"]
223 :     | toString (Div(a0)) = concat["Div<", tyToString a0, ">"]
224 :     | toString (Neg(a0)) = concat["Neg<", tyToString a0, ">"]
225 : jhr 1116 | toString (Abs(a0)) = concat["Abs<", tyToString a0, ">"]
226 : jhr 287 | toString (LT(a0)) = concat["LT<", tyToString a0, ">"]
227 :     | toString (LTE(a0)) = concat["LTE<", tyToString a0, ">"]
228 :     | toString (EQ(a0)) = concat["EQ<", tyToString a0, ">"]
229 :     | toString (NEQ(a0)) = concat["NEQ<", tyToString a0, ">"]
230 :     | toString (GT(a0)) = concat["GT<", tyToString a0, ">"]
231 :     | toString (GTE(a0)) = concat["GTE<", tyToString a0, ">"]
232 : jhr 333 | toString Not = "Not"
233 :     | toString Max = "Max"
234 :     | toString Min = "Min"
235 : jhr 1116 | toString (Lerp(a0)) = concat["Lerp<", tyToString a0, ">"]
236 : jhr 349 | toString (Dot(a0)) = concat["Dot<", intToString a0, ">"]
237 : jhr 1116 | toString (MulVecMat(a0,a1)) = concat["MulVecMat<", intToString a0, ",", intToString a1, ">"]
238 :     | toString (MulMatVec(a0,a1)) = concat["MulMatVec<", intToString a0, ",", intToString a1, ">"]
239 :     | toString (MulMatMat(a0,a1,a2)) = concat["MulMatMat<", intToString a0, ",", intToString a1, ",", intToString a2, ">"]
240 : jhr 287 | toString Cross = "Cross"
241 : jhr 420 | toString (Select(a0,a1)) = concat["Select<", tyToString a0, ",", intToString a1, ">"]
242 : jhr 1116 | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]
243 :     | toString (Normalize(a0)) = concat["Normalize<", intToString a0, ">"]
244 :     | toString (Scale(a0)) = concat["Scale<", tyToString a0, ">"]
245 : jhr 287 | toString CL = "CL"
246 :     | toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"]
247 : jhr 1116 | toString (Identity(a0)) = concat["Identity<", intToString a0, ">"]
248 :     | toString (Zero(a0)) = concat["Zero<", tyToString a0, ">"]
249 :     | toString (Trace(a0)) = concat["Trace<", intToString a0, ">"]
250 : jhr 287 | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]
251 : jhr 1116 | toString (Ceiling(a0)) = concat["Ceiling<", intToString a0, ">"]
252 : jhr 333 | toString (Floor(a0)) = concat["Floor<", intToString a0, ">"]
253 : jhr 1116 | toString (Round(a0)) = concat["Round<", intToString a0, ">"]
254 :     | toString (Trunc(a0)) = concat["Trunc<", intToString a0, ">"]
255 : jhr 287 | toString IntToReal = "IntToReal"
256 : jhr 1116 | toString (RealToInt(a0)) = concat["RealToInt<", intToString a0, ">"]
257 :     | toString (VoxelAddress(a0,a1)) = concat["VoxelAddress<", ImageInfo.toString a0, ",", intToString a1, ">"]
258 :     | toString (LoadVoxels(a0,a1)) = concat["LoadVoxels<", ImageInfo.toString a0, ",", intToString a1, ">"]
259 : jhr 450 | toString (PosToImgSpace(a0)) = concat["PosToImgSpace<", ImageInfo.toString a0, ">"]
260 : jhr 1116 | toString (TensorToWorldSpace(a0,a1)) = concat["TensorToWorldSpace<", ImageInfo.toString a0, ",", tyToString a1, ">"]
261 : jhr 332 | toString (EvalKernel(a0,a1,a2)) = concat["EvalKernel<", intToString a0, ",", Kernel.toString a1, ",", intToString a2, ">"]
262 : jhr 287 | toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"]
263 : jhr 1116 | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"]
264 : jhr 420 | toString (Input(a0,a1)) = concat["Input<", tyToString a0, ",", stringToString a1, ">"]
265 :     | toString (InputWithDefault(a0,a1)) = concat["InputWithDefault<", tyToString a0, ",", stringToString a1, ">"]
266 : jhr 287
267 :     end
268 :    
269 : jhr 392 structure MidIL = SSAFn(
270 : jhr 1232 val ilName = "mid-il"
271 : jhr 392 structure Ty = MidILTypes
272 :     structure Op = MidOps)
273 : jhr 1116
274 :     structure MidILCensus = CensusFn(MidIL)
275 :    

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