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

SCM Repository

[diderot] Annotation of /branches/pure-cfg/src/compiler/mid-il/mid-il.sml
ViewVC logotype

Annotation of /branches/pure-cfg/src/compiler/mid-il/mid-il.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 754 - (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 516 (* 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 516 (* 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 717 | 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 754 | Lerp of ty
47 : jhr 349 | Dot of int
48 : jhr 287 | Cross
49 : jhr 420 | Select of ty * int
50 : jhr 349 | Norm of int
51 : jhr 717 | Normalize of int
52 : jhr 349 | Scale of int
53 :     | InvScale of int
54 : jhr 287 | CL
55 :     | PrincipleEvec of ty
56 : jhr 683 | Trace of int
57 : jhr 287 | Subscript of ty
58 : jhr 565 | Ceiling of int
59 : jhr 333 | Floor of int
60 : jhr 565 | Round of int
61 :     | Trunc of int
62 : jhr 287 | IntToReal
63 : jhr 565 | RealToInt of int
64 : jhr 548 | VoxelAddress of ImageInfo.info
65 :     | LoadVoxels of ImageInfo.info * int
66 :     | PosToImgSpace of ImageInfo.info
67 :     | GradToWorldSpace of ImageInfo.info
68 : jhr 328 | EvalKernel of int * Kernel.kernel * int
69 : jhr 287 | LoadImage of ImageInfo.info
70 : jhr 548 | Inside of ImageInfo.info * int
71 : jhr 420 | Input of ty * string
72 :     | InputWithDefault of ty * string
73 : jhr 287
74 :     fun arity (Add _) = 2
75 :     | arity (Sub _) = 2
76 :     | arity (Mul _) = 2
77 :     | arity (Div _) = 2
78 :     | arity (Neg _) = 1
79 : jhr 717 | arity (Abs _) = 1
80 : jhr 287 | arity (LT _) = 2
81 :     | arity (LTE _) = 2
82 :     | arity (EQ _) = 2
83 :     | arity (NEQ _) = 2
84 :     | arity (GT _) = 2
85 :     | arity (GTE _) = 2
86 : jhr 333 | arity Not = 1
87 :     | arity Max = 2
88 :     | arity Min = 2
89 : jhr 754 | arity (Lerp _) = 3
90 : jhr 287 | arity (Dot _) = 2
91 :     | arity Cross = 2
92 :     | arity (Select _) = 1
93 :     | arity (Norm _) = 1
94 : jhr 717 | arity (Normalize _) = 1
95 : jhr 287 | arity (Scale _) = 2
96 :     | arity (InvScale _) = 2
97 :     | arity CL = 1
98 :     | arity (PrincipleEvec _) = 2
99 : jhr 683 | arity (Trace _) = 1
100 : jhr 287 | arity (Subscript _) = 2
101 : jhr 565 | arity (Ceiling _) = 1
102 : jhr 333 | arity (Floor _) = 1
103 : jhr 565 | arity (Round _) = 1
104 :     | arity (Trunc _) = 1
105 : jhr 287 | arity IntToReal = 1
106 : jhr 565 | arity (RealToInt _) = 1
107 : jhr 287 | arity (VoxelAddress _) = ~1
108 :     | arity (LoadVoxels _) = 1
109 : jhr 517 | arity (PosToImgSpace _) = 2
110 :     | arity (GradToWorldSpace _) = 2
111 : jhr 328 | arity (EvalKernel _) = 1
112 : jhr 517 | arity (LoadImage _) = 1
113 :     | arity (Inside _) = 2
114 : jhr 287 | arity (Input _) = 0
115 :     | arity (InputWithDefault _) = 1
116 :    
117 :     fun same (Add(a0), Add(b0)) = samety(a0, b0)
118 :     | same (Sub(a0), Sub(b0)) = samety(a0, b0)
119 :     | same (Mul(a0), Mul(b0)) = samety(a0, b0)
120 :     | same (Div(a0), Div(b0)) = samety(a0, b0)
121 :     | same (Neg(a0), Neg(b0)) = samety(a0, b0)
122 : jhr 717 | same (Abs(a0), Abs(b0)) = samety(a0, b0)
123 : jhr 287 | same (LT(a0), LT(b0)) = samety(a0, b0)
124 :     | same (LTE(a0), LTE(b0)) = samety(a0, b0)
125 :     | same (EQ(a0), EQ(b0)) = samety(a0, b0)
126 :     | same (NEQ(a0), NEQ(b0)) = samety(a0, b0)
127 :     | same (GT(a0), GT(b0)) = samety(a0, b0)
128 :     | same (GTE(a0), GTE(b0)) = samety(a0, b0)
129 : jhr 333 | same (Not, Not) = true
130 :     | same (Max, Max) = true
131 :     | same (Min, Min) = true
132 : jhr 754 | same (Lerp(a0), Lerp(b0)) = samety(a0, b0)
133 : jhr 349 | same (Dot(a0), Dot(b0)) = sameint(a0, b0)
134 : jhr 287 | same (Cross, Cross) = true
135 : jhr 420 | same (Select(a0,a1), Select(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1)
136 : jhr 349 | same (Norm(a0), Norm(b0)) = sameint(a0, b0)
137 : jhr 717 | same (Normalize(a0), Normalize(b0)) = sameint(a0, b0)
138 : jhr 349 | same (Scale(a0), Scale(b0)) = sameint(a0, b0)
139 :     | same (InvScale(a0), InvScale(b0)) = sameint(a0, b0)
140 : jhr 287 | same (CL, CL) = true
141 :     | same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0)
142 : jhr 683 | same (Trace(a0), Trace(b0)) = sameint(a0, b0)
143 : jhr 287 | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)
144 : jhr 565 | same (Ceiling(a0), Ceiling(b0)) = sameint(a0, b0)
145 : jhr 333 | same (Floor(a0), Floor(b0)) = sameint(a0, b0)
146 : jhr 565 | same (Round(a0), Round(b0)) = sameint(a0, b0)
147 :     | same (Trunc(a0), Trunc(b0)) = sameint(a0, b0)
148 : jhr 287 | same (IntToReal, IntToReal) = true
149 : jhr 565 | same (RealToInt(a0), RealToInt(b0)) = sameint(a0, b0)
150 : jhr 548 | same (VoxelAddress(a0), VoxelAddress(b0)) = ImageInfo.same(a0, b0)
151 :     | same (LoadVoxels(a0,a1), LoadVoxels(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1)
152 :     | same (PosToImgSpace(a0), PosToImgSpace(b0)) = ImageInfo.same(a0, b0)
153 :     | same (GradToWorldSpace(a0), GradToWorldSpace(b0)) = ImageInfo.same(a0, b0)
154 : jhr 328 | same (EvalKernel(a0,a1,a2), EvalKernel(b0,b1,b2)) = sameint(a0, b0) andalso Kernel.same(a1, b1) andalso sameint(a2, b2)
155 : jhr 287 | same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0)
156 : jhr 548 | same (Inside(a0,a1), Inside(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1)
157 : jhr 420 | same (Input(a0,a1), Input(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
158 :     | same (InputWithDefault(a0,a1), InputWithDefault(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
159 : jhr 287 | same _ = false
160 :    
161 :     fun hash (Add(a0)) = 0w3 + hashty a0
162 :     | hash (Sub(a0)) = 0w5 + hashty a0
163 :     | hash (Mul(a0)) = 0w7 + hashty a0
164 :     | hash (Div(a0)) = 0w11 + hashty a0
165 :     | hash (Neg(a0)) = 0w13 + hashty a0
166 : jhr 717 | hash (Abs(a0)) = 0w17 + hashty a0
167 :     | hash (LT(a0)) = 0w19 + hashty a0
168 :     | hash (LTE(a0)) = 0w23 + hashty a0
169 :     | hash (EQ(a0)) = 0w29 + hashty a0
170 :     | hash (NEQ(a0)) = 0w31 + hashty a0
171 :     | hash (GT(a0)) = 0w37 + hashty a0
172 :     | hash (GTE(a0)) = 0w41 + hashty a0
173 :     | hash Not = 0w43
174 :     | hash Max = 0w47
175 :     | hash Min = 0w53
176 : jhr 754 | hash (Lerp(a0)) = 0w59 + hashty a0
177 :     | hash (Dot(a0)) = 0w61 + hashint a0
178 :     | hash Cross = 0w67
179 :     | hash (Select(a0,a1)) = 0w71 + hashty a0 + hashint a1
180 :     | hash (Norm(a0)) = 0w73 + hashint a0
181 :     | hash (Normalize(a0)) = 0w79 + hashint a0
182 :     | hash (Scale(a0)) = 0w83 + hashint a0
183 :     | hash (InvScale(a0)) = 0w89 + hashint a0
184 :     | hash CL = 0w97
185 :     | hash (PrincipleEvec(a0)) = 0w101 + hashty a0
186 :     | hash (Trace(a0)) = 0w103 + hashint a0
187 :     | hash (Subscript(a0)) = 0w107 + hashty a0
188 :     | hash (Ceiling(a0)) = 0w109 + hashint a0
189 :     | hash (Floor(a0)) = 0w113 + hashint a0
190 :     | hash (Round(a0)) = 0w127 + hashint a0
191 :     | hash (Trunc(a0)) = 0w131 + hashint a0
192 :     | hash IntToReal = 0w137
193 :     | hash (RealToInt(a0)) = 0w139 + hashint a0
194 :     | hash (VoxelAddress(a0)) = 0w149 + ImageInfo.hash a0
195 :     | hash (LoadVoxels(a0,a1)) = 0w151 + ImageInfo.hash a0 + hashint a1
196 :     | hash (PosToImgSpace(a0)) = 0w157 + ImageInfo.hash a0
197 :     | hash (GradToWorldSpace(a0)) = 0w163 + ImageInfo.hash a0
198 :     | hash (EvalKernel(a0,a1,a2)) = 0w167 + hashint a0 + Kernel.hash a1 + hashint a2
199 :     | hash (LoadImage(a0)) = 0w173 + ImageInfo.hash a0
200 :     | hash (Inside(a0,a1)) = 0w179 + ImageInfo.hash a0 + hashint a1
201 :     | hash (Input(a0,a1)) = 0w181 + hashty a0 + hashstring a1
202 :     | hash (InputWithDefault(a0,a1)) = 0w191 + hashty a0 + hashstring a1
203 : jhr 287
204 :     fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]
205 :     | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]
206 :     | toString (Mul(a0)) = concat["Mul<", tyToString a0, ">"]
207 :     | toString (Div(a0)) = concat["Div<", tyToString a0, ">"]
208 :     | toString (Neg(a0)) = concat["Neg<", tyToString a0, ">"]
209 : jhr 717 | toString (Abs(a0)) = concat["Abs<", tyToString a0, ">"]
210 : jhr 287 | toString (LT(a0)) = concat["LT<", tyToString a0, ">"]
211 :     | toString (LTE(a0)) = concat["LTE<", tyToString a0, ">"]
212 :     | toString (EQ(a0)) = concat["EQ<", tyToString a0, ">"]
213 :     | toString (NEQ(a0)) = concat["NEQ<", tyToString a0, ">"]
214 :     | toString (GT(a0)) = concat["GT<", tyToString a0, ">"]
215 :     | toString (GTE(a0)) = concat["GTE<", tyToString a0, ">"]
216 : jhr 333 | toString Not = "Not"
217 :     | toString Max = "Max"
218 :     | toString Min = "Min"
219 : jhr 754 | toString (Lerp(a0)) = concat["Lerp<", tyToString a0, ">"]
220 : jhr 349 | toString (Dot(a0)) = concat["Dot<", intToString a0, ">"]
221 : jhr 287 | toString Cross = "Cross"
222 : jhr 420 | toString (Select(a0,a1)) = concat["Select<", tyToString a0, ",", intToString a1, ">"]
223 : jhr 349 | toString (Norm(a0)) = concat["Norm<", intToString a0, ">"]
224 : jhr 717 | toString (Normalize(a0)) = concat["Normalize<", intToString a0, ">"]
225 : jhr 349 | toString (Scale(a0)) = concat["Scale<", intToString a0, ">"]
226 :     | toString (InvScale(a0)) = concat["InvScale<", intToString a0, ">"]
227 : jhr 287 | toString CL = "CL"
228 :     | toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"]
229 : jhr 683 | toString (Trace(a0)) = concat["Trace<", intToString a0, ">"]
230 : jhr 287 | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]
231 : jhr 565 | toString (Ceiling(a0)) = concat["Ceiling<", intToString a0, ">"]
232 : jhr 333 | toString (Floor(a0)) = concat["Floor<", intToString a0, ">"]
233 : jhr 565 | toString (Round(a0)) = concat["Round<", intToString a0, ">"]
234 :     | toString (Trunc(a0)) = concat["Trunc<", intToString a0, ">"]
235 : jhr 287 | toString IntToReal = "IntToReal"
236 : jhr 565 | toString (RealToInt(a0)) = concat["RealToInt<", intToString a0, ">"]
237 : jhr 548 | toString (VoxelAddress(a0)) = concat["VoxelAddress<", ImageInfo.toString a0, ">"]
238 :     | toString (LoadVoxels(a0,a1)) = concat["LoadVoxels<", ImageInfo.toString a0, ",", intToString a1, ">"]
239 :     | toString (PosToImgSpace(a0)) = concat["PosToImgSpace<", ImageInfo.toString a0, ">"]
240 :     | toString (GradToWorldSpace(a0)) = concat["GradToWorldSpace<", ImageInfo.toString a0, ">"]
241 : jhr 332 | toString (EvalKernel(a0,a1,a2)) = concat["EvalKernel<", intToString a0, ",", Kernel.toString a1, ",", intToString a2, ">"]
242 : jhr 287 | toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"]
243 : jhr 548 | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"]
244 : jhr 420 | toString (Input(a0,a1)) = concat["Input<", tyToString a0, ",", stringToString a1, ">"]
245 :     | toString (InputWithDefault(a0,a1)) = concat["InputWithDefault<", tyToString a0, ",", stringToString a1, ">"]
246 : jhr 287
247 :     end
248 :    
249 : jhr 392 structure MidIL = SSAFn(
250 :     structure Ty = MidILTypes
251 :     structure Op = MidOps)
252 : jhr 539
253 :     structure MidILCensus = CensusFn(MidIL)
254 : jhr 546

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