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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 336 - (view) (download)

1 : jhr 166 (* high-il.sml
2 :     *
3 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *
6 :     * High-level version of the Diderot IL.
7 : jhr 186 *
8 :     * Note: this file is generated from gen/high-il.spec and gen/high-il.in.
9 : jhr 166 *)
10 :    
11 :     structure HighOps =
12 :     struct
13 :    
14 : jhr 187 datatype ty = BoolTy | StringTy | IntTy | TensorTy of int list
15 : jhr 166
16 : jhr 336 (* required helper functions for the "ty" type *)
17 : jhr 187 fun samety (ty1 : ty, ty2) = (ty1 = ty2)
18 :     fun hashty BoolTy = 0w1
19 :     | hashty StringTy = 0w2
20 :     | hashty IntTy = 0w3
21 :     | hashty (TensorTy dd) = List.foldl (fn (d, s) => Word.fromInt d + s) 0w4 dd
22 :     fun tyToString BoolTy = "bool"
23 :     | tyToString StringTy = "string"
24 :     | tyToString IntTy = "int"
25 : jhr 328 | tyToString (TensorTy[]) = "real"
26 : jhr 187 | tyToString (TensorTy dd) = String.concat[
27 :     "tensor[", String.concatWith "," (List.map Int.toString dd), "]"
28 :     ]
29 : jhr 166
30 : jhr 336 (* required helper functions for the string type *)
31 : jhr 226 fun samestring (s1 : string, s2) = (s1 = s2)
32 :     val hashstring = HashString.hashString
33 :     fun stringToString s = String.concat["\"", s, "\""]
34 :    
35 : jhr 166 datatype rator
36 : jhr 186 = Add of ty
37 :     | Sub of ty
38 :     | Mul of ty
39 :     | Div of ty
40 : jhr 166 | Neg of ty
41 : jhr 186 | LT of ty
42 :     | LTE of ty
43 :     | EQ of ty
44 :     | NEQ of ty
45 :     | GT of ty
46 :     | GTE of ty
47 :     | Dot of ty
48 :     | Cross
49 :     | Norm of ty
50 :     | Scale of ty
51 :     | InvScale of ty
52 :     | CL
53 :     | PrincipleEvec of ty
54 : jhr 166 | Subscript of ty
55 : jhr 186 | Max
56 :     | Min
57 :     | Sin
58 :     | Cos
59 : jhr 166 | Pow
60 : jhr 186 | Not
61 : jhr 166 | IntToReal
62 :     | TruncToInt
63 :     | RoundToInt
64 :     | CeilToInt
65 :     | FloorToInt
66 : jhr 195 | Kernel of Kernel.kernel
67 : jhr 186 | LoadImage of ImageInfo.info
68 : jhr 197 | Convolve
69 : jhr 166 | Inside
70 :     | Field of FieldDef.field_def
71 : jhr 195 | AddField
72 :     | ScaleField
73 :     | NegField
74 :     | DiffField
75 : jhr 166 | Probe
76 : jhr 186 | Transform of ImageInfo.info
77 : jhr 226 | Input of string
78 :     | InputWithDefault of string
79 : jhr 166
80 :     fun arity (Add _) = 2
81 :     | arity (Sub _) = 2
82 :     | arity (Mul _) = 2
83 :     | arity (Div _) = 2
84 :     | arity (Neg _) = 1
85 : jhr 180 | arity (LT _) = 2
86 :     | arity (LTE _) = 2
87 :     | arity (EQ _) = 2
88 :     | arity (NEQ _) = 2
89 :     | arity (GT _) = 2
90 :     | arity (GTE _) = 2
91 : jhr 166 | arity (Dot _) = 2
92 :     | arity Cross = 2
93 :     | arity (Norm _) = 1
94 :     | arity (Scale _) = 2
95 : jhr 186 | arity (InvScale _) = 2
96 :     | arity CL = 1
97 :     | arity (PrincipleEvec _) = 2
98 : jhr 166 | arity (Subscript _) = 2
99 : jhr 186 | arity Max = 2
100 :     | arity Min = 2
101 : jhr 166 | arity Sin = 1
102 :     | arity Cos = 1
103 :     | arity Pow = 2
104 : jhr 180 | arity Not = 1
105 : jhr 166 | arity IntToReal = 1
106 :     | arity TruncToInt = 1
107 :     | arity RoundToInt = 1
108 :     | arity CeilToInt = 1
109 :     | arity FloorToInt = 1
110 : jhr 195 | arity (Kernel _) = 0
111 : jhr 226 | arity (LoadImage _) = 0
112 : jhr 197 | arity Convolve = 2
113 : jhr 166 | arity Inside = 2
114 :     | arity (Field _) = 0
115 : jhr 195 | arity AddField = 2
116 :     | arity ScaleField = 2
117 :     | arity NegField = 1
118 :     | arity DiffField = 1
119 : jhr 166 | arity Probe = 2
120 :     | arity (Transform _) = 1
121 : jhr 226 | arity (Input _) = 0
122 :     | arity (InputWithDefault _) = 1
123 : jhr 166
124 : jhr 282 fun same (Add(a0), Add(b0)) = samety(a0, b0)
125 :     | same (Sub(a0), Sub(b0)) = samety(a0, b0)
126 :     | same (Mul(a0), Mul(b0)) = samety(a0, b0)
127 :     | same (Div(a0), Div(b0)) = samety(a0, b0)
128 :     | same (Neg(a0), Neg(b0)) = samety(a0, b0)
129 :     | same (LT(a0), LT(b0)) = samety(a0, b0)
130 :     | same (LTE(a0), LTE(b0)) = samety(a0, b0)
131 :     | same (EQ(a0), EQ(b0)) = samety(a0, b0)
132 :     | same (NEQ(a0), NEQ(b0)) = samety(a0, b0)
133 :     | same (GT(a0), GT(b0)) = samety(a0, b0)
134 :     | same (GTE(a0), GTE(b0)) = samety(a0, b0)
135 :     | same (Dot(a0), Dot(b0)) = samety(a0, b0)
136 : jhr 166 | same (Cross, Cross) = true
137 : jhr 282 | same (Norm(a0), Norm(b0)) = samety(a0, b0)
138 :     | same (Scale(a0), Scale(b0)) = samety(a0, b0)
139 :     | same (InvScale(a0), InvScale(b0)) = samety(a0, b0)
140 : jhr 166 | same (CL, CL) = true
141 : jhr 282 | same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0)
142 :     | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)
143 : jhr 166 | same (Max, Max) = true
144 :     | same (Min, Min) = true
145 :     | same (Sin, Sin) = true
146 :     | same (Cos, Cos) = true
147 :     | same (Pow, Pow) = true
148 : jhr 180 | same (Not, Not) = true
149 : jhr 166 | same (IntToReal, IntToReal) = true
150 :     | same (TruncToInt, TruncToInt) = true
151 :     | same (RoundToInt, RoundToInt) = true
152 :     | same (CeilToInt, CeilToInt) = true
153 :     | same (FloorToInt, FloorToInt) = true
154 : jhr 282 | same (Kernel(a0), Kernel(b0)) = Kernel.same(a0, b0)
155 :     | same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0)
156 : jhr 197 | same (Convolve, Convolve) = true
157 : jhr 166 | same (Inside, Inside) = true
158 : jhr 282 | same (Field(a0), Field(b0)) = FieldDef.same(a0, b0)
159 : jhr 195 | same (AddField, AddField) = true
160 :     | same (ScaleField, ScaleField) = true
161 :     | same (NegField, NegField) = true
162 :     | same (DiffField, DiffField) = true
163 : jhr 166 | same (Probe, Probe) = true
164 : jhr 282 | same (Transform(a0), Transform(b0)) = ImageInfo.same(a0, b0)
165 :     | same (Input(a0), Input(b0)) = samestring(a0, b0)
166 :     | same (InputWithDefault(a0), InputWithDefault(b0)) = samestring(a0, b0)
167 : jhr 166 | same _ = false
168 :    
169 : jhr 282 fun hash (Add(a0)) = 0w3 + hashty a0
170 :     | hash (Sub(a0)) = 0w5 + hashty a0
171 :     | hash (Mul(a0)) = 0w7 + hashty a0
172 :     | hash (Div(a0)) = 0w11 + hashty a0
173 :     | hash (Neg(a0)) = 0w13 + hashty a0
174 :     | hash (LT(a0)) = 0w17 + hashty a0
175 :     | hash (LTE(a0)) = 0w19 + hashty a0
176 :     | hash (EQ(a0)) = 0w23 + hashty a0
177 :     | hash (NEQ(a0)) = 0w29 + hashty a0
178 :     | hash (GT(a0)) = 0w31 + hashty a0
179 :     | hash (GTE(a0)) = 0w37 + hashty a0
180 :     | hash (Dot(a0)) = 0w41 + hashty a0
181 : jhr 186 | hash Cross = 0w43
182 : jhr 282 | hash (Norm(a0)) = 0w47 + hashty a0
183 :     | hash (Scale(a0)) = 0w53 + hashty a0
184 :     | hash (InvScale(a0)) = 0w59 + hashty a0
185 : jhr 186 | hash CL = 0w61
186 : jhr 282 | hash (PrincipleEvec(a0)) = 0w67 + hashty a0
187 :     | hash (Subscript(a0)) = 0w71 + hashty a0
188 : jhr 186 | hash Max = 0w73
189 :     | hash Min = 0w79
190 :     | hash Sin = 0w83
191 :     | hash Cos = 0w89
192 :     | hash Pow = 0w97
193 :     | hash Not = 0w101
194 :     | hash IntToReal = 0w103
195 :     | hash TruncToInt = 0w107
196 :     | hash RoundToInt = 0w109
197 :     | hash CeilToInt = 0w113
198 :     | hash FloorToInt = 0w127
199 : jhr 282 | hash (Kernel(a0)) = 0w131 + Kernel.hash a0
200 :     | hash (LoadImage(a0)) = 0w137 + ImageInfo.hash a0
201 : jhr 197 | hash Convolve = 0w139
202 :     | hash Inside = 0w149
203 : jhr 282 | hash (Field(a0)) = 0w151 + FieldDef.hash a0
204 : jhr 197 | hash AddField = 0w157
205 :     | hash ScaleField = 0w163
206 :     | hash NegField = 0w167
207 :     | hash DiffField = 0w173
208 :     | hash Probe = 0w179
209 : jhr 282 | hash (Transform(a0)) = 0w181 + ImageInfo.hash a0
210 :     | hash (Input(a0)) = 0w191 + hashstring a0
211 :     | hash (InputWithDefault(a0)) = 0w193 + hashstring a0
212 : jhr 166
213 : jhr 282 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 :     | toString (LT(a0)) = concat["LT<", tyToString a0, ">"]
219 :     | toString (LTE(a0)) = concat["LTE<", tyToString a0, ">"]
220 :     | toString (EQ(a0)) = concat["EQ<", tyToString a0, ">"]
221 :     | toString (NEQ(a0)) = concat["NEQ<", tyToString a0, ">"]
222 :     | toString (GT(a0)) = concat["GT<", tyToString a0, ">"]
223 :     | toString (GTE(a0)) = concat["GTE<", tyToString a0, ">"]
224 :     | toString (Dot(a0)) = concat["Dot<", tyToString a0, ">"]
225 : jhr 186 | toString Cross = "Cross"
226 : jhr 282 | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]
227 :     | toString (Scale(a0)) = concat["Scale<", tyToString a0, ">"]
228 :     | toString (InvScale(a0)) = concat["InvScale<", tyToString a0, ">"]
229 : jhr 186 | toString CL = "CL"
230 : jhr 282 | toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"]
231 :     | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]
232 : jhr 186 | toString Max = "Max"
233 :     | toString Min = "Min"
234 :     | toString Sin = "Sin"
235 :     | toString Cos = "Cos"
236 :     | toString Pow = "Pow"
237 :     | toString Not = "Not"
238 :     | toString IntToReal = "IntToReal"
239 :     | toString TruncToInt = "TruncToInt"
240 :     | toString RoundToInt = "RoundToInt"
241 :     | toString CeilToInt = "CeilToInt"
242 :     | toString FloorToInt = "FloorToInt"
243 : jhr 282 | toString (Kernel(a0)) = concat["Kernel<", Kernel.toString a0, ">"]
244 :     | toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"]
245 : jhr 197 | toString Convolve = "Convolve"
246 : jhr 186 | toString Inside = "Inside"
247 : jhr 282 | toString (Field(a0)) = concat["Field<", FieldDef.toString a0, ">"]
248 : jhr 195 | toString AddField = "AddField"
249 :     | toString ScaleField = "ScaleField"
250 :     | toString NegField = "NegField"
251 :     | toString DiffField = "DiffField"
252 : jhr 186 | toString Probe = "Probe"
253 : jhr 282 | toString (Transform(a0)) = concat["Transform<", ImageInfo.toString a0, ">"]
254 :     | toString (Input(a0)) = concat["Input<", stringToString a0, ">"]
255 :     | toString (InputWithDefault(a0)) = concat["InputWithDefault<", stringToString a0, ">"]
256 : jhr 166
257 :     end
258 :    
259 :     structure HighIL = SSAFn(HighOps)

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