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

SCM Repository

[diderot] Annotation of /branches/pure-cfg/src/compiler/high-il/high-il.sml
ViewVC logotype

Annotation of /branches/pure-cfg/src/compiler/high-il/high-il.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 548 - (view) (download)

1 : jhr 166 (* high-il.sml
2 :     *
3 : jhr 435 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 : jhr 166 * 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 516 (* required helper functions for the int type *)
21 :     fun sameint (i1 : int, i2) = (i1 = i2)
22 :     fun hashint i = Word.fromInt i
23 :     fun intToString i = Int.toString i
24 :    
25 : jhr 336 (* required helper functions for the string type *)
26 : jhr 226 fun samestring (s1 : string, s2) = (s1 = s2)
27 :     val hashstring = HashString.hashString
28 :     fun stringToString s = String.concat["\"", s, "\""]
29 :    
30 : jhr 407 (* required helper functions for the mask type *)
31 : jhr 400 type mask = bool list
32 :     val samemask : (mask * mask -> bool) = (op =)
33 :     fun hashmask m =
34 :     List.foldl (fn (false, w) => w+w | (true, w) => w+w+0w1)
35 :     (Word.fromInt(List.length m)) m
36 :     fun maskToString m =
37 :     String.concat(List.map (fn true => "_" | false => ":") m)
38 :    
39 : jhr 166 datatype rator
40 : jhr 186 = Add of ty
41 :     | Sub of ty
42 :     | Mul of ty
43 :     | Div of ty
44 : jhr 166 | Neg of ty
45 : jhr 186 | LT of ty
46 :     | LTE of ty
47 :     | EQ of ty
48 :     | NEQ of ty
49 :     | GT of ty
50 :     | GTE of ty
51 : jhr 400 | Max
52 :     | Min
53 :     | Sin
54 :     | Cos
55 :     | Pow
56 :     | Not
57 : jhr 186 | Dot of ty
58 :     | Cross
59 :     | Norm of ty
60 :     | Scale of ty
61 :     | InvScale of ty
62 :     | CL
63 :     | PrincipleEvec of ty
64 : jhr 400 | Slice of ty * mask
65 : jhr 166 | Subscript of ty
66 :     | IntToReal
67 :     | TruncToInt
68 :     | RoundToInt
69 :     | CeilToInt
70 :     | FloorToInt
71 : jhr 516 | Kernel of Kernel.kernel * int
72 : jhr 186 | LoadImage of ImageInfo.info
73 : jhr 517 | Field of int
74 : jhr 548 | Inside of int
75 : jhr 195 | AddField
76 :     | ScaleField
77 :     | NegField
78 :     | DiffField
79 : jhr 407 | Probe of ty * ty
80 :     | Input of ty * string
81 :     | InputWithDefault of ty * string
82 : jhr 166
83 :     fun arity (Add _) = 2
84 :     | arity (Sub _) = 2
85 :     | arity (Mul _) = 2
86 :     | arity (Div _) = 2
87 :     | arity (Neg _) = 1
88 : jhr 180 | arity (LT _) = 2
89 :     | arity (LTE _) = 2
90 :     | arity (EQ _) = 2
91 :     | arity (NEQ _) = 2
92 :     | arity (GT _) = 2
93 :     | arity (GTE _) = 2
94 : jhr 400 | arity Max = 2
95 :     | arity Min = 2
96 :     | arity Sin = 1
97 :     | arity Cos = 1
98 :     | arity Pow = 2
99 :     | arity Not = 1
100 : jhr 166 | arity (Dot _) = 2
101 :     | arity Cross = 2
102 :     | arity (Norm _) = 1
103 :     | arity (Scale _) = 2
104 : jhr 186 | arity (InvScale _) = 2
105 :     | arity CL = 1
106 :     | arity (PrincipleEvec _) = 2
107 : jhr 400 | arity (Slice _) = 1
108 :     | arity (Subscript _) = ~1
109 : jhr 166 | arity IntToReal = 1
110 :     | arity TruncToInt = 1
111 :     | arity RoundToInt = 1
112 :     | arity CeilToInt = 1
113 :     | arity FloorToInt = 1
114 : jhr 195 | arity (Kernel _) = 0
115 : jhr 516 | arity (LoadImage _) = 1
116 : jhr 517 | arity (Field _) = 2
117 : jhr 407 | arity (Inside _) = 2
118 : jhr 195 | arity AddField = 2
119 :     | arity ScaleField = 2
120 :     | arity NegField = 1
121 :     | arity DiffField = 1
122 : jhr 407 | arity (Probe _) = 2
123 : jhr 226 | arity (Input _) = 0
124 :     | arity (InputWithDefault _) = 1
125 : jhr 166
126 : jhr 282 fun same (Add(a0), Add(b0)) = samety(a0, b0)
127 :     | same (Sub(a0), Sub(b0)) = samety(a0, b0)
128 :     | same (Mul(a0), Mul(b0)) = samety(a0, b0)
129 :     | same (Div(a0), Div(b0)) = samety(a0, b0)
130 :     | same (Neg(a0), Neg(b0)) = samety(a0, b0)
131 :     | same (LT(a0), LT(b0)) = samety(a0, b0)
132 :     | same (LTE(a0), LTE(b0)) = samety(a0, b0)
133 :     | same (EQ(a0), EQ(b0)) = samety(a0, b0)
134 :     | same (NEQ(a0), NEQ(b0)) = samety(a0, b0)
135 :     | same (GT(a0), GT(b0)) = samety(a0, b0)
136 :     | same (GTE(a0), GTE(b0)) = samety(a0, b0)
137 : jhr 400 | same (Max, Max) = true
138 :     | same (Min, Min) = true
139 :     | same (Sin, Sin) = true
140 :     | same (Cos, Cos) = true
141 :     | same (Pow, Pow) = true
142 :     | same (Not, Not) = true
143 : jhr 282 | same (Dot(a0), Dot(b0)) = samety(a0, b0)
144 : jhr 166 | same (Cross, Cross) = true
145 : jhr 282 | same (Norm(a0), Norm(b0)) = samety(a0, b0)
146 :     | same (Scale(a0), Scale(b0)) = samety(a0, b0)
147 :     | same (InvScale(a0), InvScale(b0)) = samety(a0, b0)
148 : jhr 166 | same (CL, CL) = true
149 : jhr 282 | same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0)
150 : jhr 400 | same (Slice(a0,a1), Slice(b0,b1)) = samety(a0, b0) andalso samemask(a1, b1)
151 : jhr 282 | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)
152 : jhr 166 | same (IntToReal, IntToReal) = true
153 :     | same (TruncToInt, TruncToInt) = true
154 :     | same (RoundToInt, RoundToInt) = true
155 :     | same (CeilToInt, CeilToInt) = true
156 :     | same (FloorToInt, FloorToInt) = true
157 : jhr 516 | same (Kernel(a0,a1), Kernel(b0,b1)) = Kernel.same(a0, b0) andalso sameint(a1, b1)
158 : jhr 282 | same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0)
159 : jhr 517 | same (Field(a0), Field(b0)) = sameint(a0, b0)
160 : jhr 548 | same (Inside(a0), Inside(b0)) = sameint(a0, b0)
161 : jhr 195 | same (AddField, AddField) = true
162 :     | same (ScaleField, ScaleField) = true
163 :     | same (NegField, NegField) = true
164 :     | same (DiffField, DiffField) = true
165 : jhr 407 | same (Probe(a0,a1), Probe(b0,b1)) = samety(a0, b0) andalso samety(a1, b1)
166 :     | same (Input(a0,a1), Input(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
167 :     | same (InputWithDefault(a0,a1), InputWithDefault(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
168 : jhr 166 | same _ = false
169 :    
170 : jhr 282 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 :     | hash (LT(a0)) = 0w17 + hashty a0
176 :     | hash (LTE(a0)) = 0w19 + hashty a0
177 :     | hash (EQ(a0)) = 0w23 + hashty a0
178 :     | hash (NEQ(a0)) = 0w29 + hashty a0
179 :     | hash (GT(a0)) = 0w31 + hashty a0
180 :     | hash (GTE(a0)) = 0w37 + hashty a0
181 : jhr 400 | hash Max = 0w41
182 :     | hash Min = 0w43
183 :     | hash Sin = 0w47
184 :     | hash Cos = 0w53
185 :     | hash Pow = 0w59
186 :     | hash Not = 0w61
187 :     | hash (Dot(a0)) = 0w67 + hashty a0
188 :     | hash Cross = 0w71
189 :     | hash (Norm(a0)) = 0w73 + hashty a0
190 :     | hash (Scale(a0)) = 0w79 + hashty a0
191 :     | hash (InvScale(a0)) = 0w83 + hashty a0
192 :     | hash CL = 0w89
193 :     | hash (PrincipleEvec(a0)) = 0w97 + hashty a0
194 :     | hash (Slice(a0,a1)) = 0w101 + hashty a0 + hashmask a1
195 :     | hash (Subscript(a0)) = 0w103 + hashty a0
196 :     | hash IntToReal = 0w107
197 :     | hash TruncToInt = 0w109
198 :     | hash RoundToInt = 0w113
199 :     | hash CeilToInt = 0w127
200 :     | hash FloorToInt = 0w131
201 : jhr 516 | hash (Kernel(a0,a1)) = 0w137 + Kernel.hash a0 + hashint a1
202 : jhr 400 | hash (LoadImage(a0)) = 0w139 + ImageInfo.hash a0
203 : jhr 517 | hash (Field(a0)) = 0w149 + hashint a0
204 : jhr 548 | hash (Inside(a0)) = 0w151 + hashint a0
205 : jhr 516 | hash AddField = 0w157
206 :     | hash ScaleField = 0w163
207 :     | hash NegField = 0w167
208 :     | hash DiffField = 0w173
209 :     | hash (Probe(a0,a1)) = 0w179 + hashty a0 + hashty a1
210 :     | hash (Input(a0,a1)) = 0w181 + hashty a0 + hashstring a1
211 :     | hash (InputWithDefault(a0,a1)) = 0w191 + hashty a0 + hashstring a1
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 : jhr 400 | toString Max = "Max"
225 :     | toString Min = "Min"
226 :     | toString Sin = "Sin"
227 :     | toString Cos = "Cos"
228 :     | toString Pow = "Pow"
229 :     | toString Not = "Not"
230 : jhr 282 | toString (Dot(a0)) = concat["Dot<", tyToString a0, ">"]
231 : jhr 186 | toString Cross = "Cross"
232 : jhr 282 | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]
233 :     | toString (Scale(a0)) = concat["Scale<", tyToString a0, ">"]
234 :     | toString (InvScale(a0)) = concat["InvScale<", tyToString a0, ">"]
235 : jhr 186 | toString CL = "CL"
236 : jhr 282 | toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"]
237 : jhr 400 | toString (Slice(a0,a1)) = concat["Slice<", tyToString a0, ",", maskToString a1, ">"]
238 : jhr 282 | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]
239 : jhr 186 | toString IntToReal = "IntToReal"
240 :     | toString TruncToInt = "TruncToInt"
241 :     | toString RoundToInt = "RoundToInt"
242 :     | toString CeilToInt = "CeilToInt"
243 :     | toString FloorToInt = "FloorToInt"
244 : jhr 516 | toString (Kernel(a0,a1)) = concat["Kernel<", Kernel.toString a0, ",", intToString a1, ">"]
245 : jhr 282 | toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"]
246 : jhr 517 | toString (Field(a0)) = concat["Field<", intToString a0, ">"]
247 : jhr 548 | toString (Inside(a0)) = concat["Inside<", intToString a0, ">"]
248 : jhr 195 | toString AddField = "AddField"
249 :     | toString ScaleField = "ScaleField"
250 :     | toString NegField = "NegField"
251 :     | toString DiffField = "DiffField"
252 : jhr 407 | toString (Probe(a0,a1)) = concat["Probe<", tyToString a0, ",", tyToString a1, ">"]
253 :     | toString (Input(a0,a1)) = concat["Input<", tyToString a0, ",", stringToString a1, ">"]
254 :     | toString (InputWithDefault(a0,a1)) = concat["InputWithDefault<", tyToString a0, ",", stringToString a1, ">"]
255 : jhr 166
256 :     end
257 :    
258 : jhr 392 structure HighIL = SSAFn(
259 :     structure Ty = HighILTypes
260 :     structure Op = HighOps)
261 : jhr 539
262 :     structure HighILCensus = CensusFn(HighIL)
263 : jhr 546

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