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 400 - (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 392 type ty = HighILTypes.ty
15 : jhr 166
16 : jhr 392 val samety = HighILTypes.same
17 :     val hashty = HighILTypes.hash
18 :     val tyToString = HighILTypes.toString
19 : jhr 166
20 : jhr 336 (* required helper functions for the string type *)
21 : jhr 226 fun samestring (s1 : string, s2) = (s1 = s2)
22 :     val hashstring = HashString.hashString
23 :     fun stringToString s = String.concat["\"", s, "\""]
24 :    
25 : jhr 400 (* required helper functions for the mask tyoe *)
26 :     type mask = bool list
27 :     val samemask : (mask * mask -> bool) = (op =)
28 :     fun hashmask m =
29 :     List.foldl (fn (false, w) => w+w | (true, w) => w+w+0w1)
30 :     (Word.fromInt(List.length m)) m
31 :     fun maskToString m =
32 :     String.concat(List.map (fn true => "_" | false => ":") m)
33 :    
34 : jhr 166 datatype rator
35 : jhr 186 = Add of ty
36 :     | Sub of ty
37 :     | Mul of ty
38 :     | Div of ty
39 : jhr 166 | Neg of ty
40 : jhr 186 | LT of ty
41 :     | LTE of ty
42 :     | EQ of ty
43 :     | NEQ of ty
44 :     | GT of ty
45 :     | GTE of ty
46 : jhr 400 | Max
47 :     | Min
48 :     | Sin
49 :     | Cos
50 :     | Pow
51 :     | Not
52 : jhr 186 | Dot of ty
53 :     | Cross
54 :     | Norm of ty
55 :     | Scale of ty
56 :     | InvScale of ty
57 :     | CL
58 :     | PrincipleEvec of ty
59 : jhr 400 | Slice of ty * mask
60 : jhr 166 | Subscript of ty
61 :     | 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 226 | Input of string
77 :     | InputWithDefault of string
78 : jhr 166
79 :     fun arity (Add _) = 2
80 :     | arity (Sub _) = 2
81 :     | arity (Mul _) = 2
82 :     | arity (Div _) = 2
83 :     | arity (Neg _) = 1
84 : jhr 180 | arity (LT _) = 2
85 :     | arity (LTE _) = 2
86 :     | arity (EQ _) = 2
87 :     | arity (NEQ _) = 2
88 :     | arity (GT _) = 2
89 :     | arity (GTE _) = 2
90 : jhr 400 | arity Max = 2
91 :     | arity Min = 2
92 :     | arity Sin = 1
93 :     | arity Cos = 1
94 :     | arity Pow = 2
95 :     | arity Not = 1
96 : jhr 166 | arity (Dot _) = 2
97 :     | arity Cross = 2
98 :     | arity (Norm _) = 1
99 :     | arity (Scale _) = 2
100 : jhr 186 | arity (InvScale _) = 2
101 :     | arity CL = 1
102 :     | arity (PrincipleEvec _) = 2
103 : jhr 400 | arity (Slice _) = 1
104 :     | arity (Subscript _) = ~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 : jhr 226 | arity (Input _) = 0
121 :     | arity (InputWithDefault _) = 1
122 : jhr 166
123 : jhr 282 fun same (Add(a0), Add(b0)) = samety(a0, b0)
124 :     | same (Sub(a0), Sub(b0)) = samety(a0, b0)
125 :     | same (Mul(a0), Mul(b0)) = samety(a0, b0)
126 :     | same (Div(a0), Div(b0)) = samety(a0, b0)
127 :     | same (Neg(a0), Neg(b0)) = samety(a0, b0)
128 :     | 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 : jhr 400 | same (Max, Max) = true
135 :     | same (Min, Min) = true
136 :     | same (Sin, Sin) = true
137 :     | same (Cos, Cos) = true
138 :     | same (Pow, Pow) = true
139 :     | same (Not, Not) = true
140 : jhr 282 | same (Dot(a0), Dot(b0)) = samety(a0, b0)
141 : jhr 166 | same (Cross, Cross) = true
142 : jhr 282 | same (Norm(a0), Norm(b0)) = samety(a0, b0)
143 :     | same (Scale(a0), Scale(b0)) = samety(a0, b0)
144 :     | same (InvScale(a0), InvScale(b0)) = samety(a0, b0)
145 : jhr 166 | same (CL, CL) = true
146 : jhr 282 | same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0)
147 : jhr 400 | same (Slice(a0,a1), Slice(b0,b1)) = samety(a0, b0) andalso samemask(a1, b1)
148 : jhr 282 | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)
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 (Input(a0), Input(b0)) = samestring(a0, b0)
165 :     | same (InputWithDefault(a0), InputWithDefault(b0)) = samestring(a0, b0)
166 : jhr 166 | same _ = false
167 :    
168 : jhr 282 fun hash (Add(a0)) = 0w3 + hashty a0
169 :     | hash (Sub(a0)) = 0w5 + hashty a0
170 :     | hash (Mul(a0)) = 0w7 + hashty a0
171 :     | hash (Div(a0)) = 0w11 + hashty a0
172 :     | hash (Neg(a0)) = 0w13 + hashty a0
173 :     | hash (LT(a0)) = 0w17 + hashty a0
174 :     | hash (LTE(a0)) = 0w19 + hashty a0
175 :     | hash (EQ(a0)) = 0w23 + hashty a0
176 :     | hash (NEQ(a0)) = 0w29 + hashty a0
177 :     | hash (GT(a0)) = 0w31 + hashty a0
178 :     | hash (GTE(a0)) = 0w37 + hashty a0
179 : jhr 400 | hash Max = 0w41
180 :     | hash Min = 0w43
181 :     | hash Sin = 0w47
182 :     | hash Cos = 0w53
183 :     | hash Pow = 0w59
184 :     | hash Not = 0w61
185 :     | hash (Dot(a0)) = 0w67 + hashty a0
186 :     | hash Cross = 0w71
187 :     | hash (Norm(a0)) = 0w73 + hashty a0
188 :     | hash (Scale(a0)) = 0w79 + hashty a0
189 :     | hash (InvScale(a0)) = 0w83 + hashty a0
190 :     | hash CL = 0w89
191 :     | hash (PrincipleEvec(a0)) = 0w97 + hashty a0
192 :     | hash (Slice(a0,a1)) = 0w101 + hashty a0 + hashmask a1
193 :     | hash (Subscript(a0)) = 0w103 + hashty a0
194 :     | hash IntToReal = 0w107
195 :     | hash TruncToInt = 0w109
196 :     | hash RoundToInt = 0w113
197 :     | hash CeilToInt = 0w127
198 :     | hash FloorToInt = 0w131
199 :     | hash (Kernel(a0)) = 0w137 + Kernel.hash a0
200 :     | hash (LoadImage(a0)) = 0w139 + ImageInfo.hash a0
201 :     | hash Convolve = 0w149
202 :     | hash Inside = 0w151
203 :     | hash (Field(a0)) = 0w157 + FieldDef.hash a0
204 :     | hash AddField = 0w163
205 :     | hash ScaleField = 0w167
206 :     | hash NegField = 0w173
207 :     | hash DiffField = 0w179
208 :     | hash Probe = 0w181
209 :     | hash (Input(a0)) = 0w191 + hashstring a0
210 :     | hash (InputWithDefault(a0)) = 0w193 + hashstring a0
211 : jhr 166
212 : jhr 282 fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]
213 :     | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]
214 :     | toString (Mul(a0)) = concat["Mul<", tyToString a0, ">"]
215 :     | toString (Div(a0)) = concat["Div<", tyToString a0, ">"]
216 :     | toString (Neg(a0)) = concat["Neg<", tyToString a0, ">"]
217 :     | toString (LT(a0)) = concat["LT<", tyToString a0, ">"]
218 :     | toString (LTE(a0)) = concat["LTE<", tyToString a0, ">"]
219 :     | toString (EQ(a0)) = concat["EQ<", tyToString a0, ">"]
220 :     | toString (NEQ(a0)) = concat["NEQ<", tyToString a0, ">"]
221 :     | toString (GT(a0)) = concat["GT<", tyToString a0, ">"]
222 :     | toString (GTE(a0)) = concat["GTE<", tyToString a0, ">"]
223 : jhr 400 | toString Max = "Max"
224 :     | toString Min = "Min"
225 :     | toString Sin = "Sin"
226 :     | toString Cos = "Cos"
227 :     | toString Pow = "Pow"
228 :     | toString Not = "Not"
229 : jhr 282 | toString (Dot(a0)) = concat["Dot<", tyToString a0, ">"]
230 : jhr 186 | toString Cross = "Cross"
231 : jhr 282 | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]
232 :     | toString (Scale(a0)) = concat["Scale<", tyToString a0, ">"]
233 :     | toString (InvScale(a0)) = concat["InvScale<", tyToString a0, ">"]
234 : jhr 186 | toString CL = "CL"
235 : jhr 282 | toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"]
236 : jhr 400 | toString (Slice(a0,a1)) = concat["Slice<", tyToString a0, ",", maskToString a1, ">"]
237 : jhr 282 | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]
238 : jhr 186 | 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 (Input(a0)) = concat["Input<", stringToString a0, ">"]
254 :     | toString (InputWithDefault(a0)) = concat["InputWithDefault<", stringToString a0, ">"]
255 : jhr 166
256 :     end
257 :    
258 : jhr 392 structure HighIL = SSAFn(
259 :     structure Ty = HighILTypes
260 :     structure Op = HighOps)

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