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

SCM Repository

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

Annotation of /branches/charisee/src/compiler/low-il/low-il.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1116 - (view) (download)
Original Path: trunk/src/compiler/low-il/low-il.sml

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

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