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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 196 - (view) (download)

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

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