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 197 - (view) (download)
Original Path: trunk/src/compiler/IL/high-il.sml

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

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