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

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