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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1301 - (view) (download)

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

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