SCM Repository
Diff of /trunk/src/compiler/IL/gen/high-il.sml
Parent Directory
|
Revision Log
|
Patch
revision 195, Mon Aug 2 19:09:04 2010 UTC | revision 196, Mon Aug 2 19:10:49 2010 UTC | |
---|---|---|
# | Line 11 | Line 11 |
11 | structure HighOps = | structure HighOps = |
12 | struct | struct |
13 | ||
14 | type ty = BoolTy | StringTy | IntTy | TensorTy of int list | datatype ty = BoolTy | StringTy | IntTy | TensorTy of int list |
15 | ||
16 | fun sameTy (ty1 : ty, ty2) = (ty1 = ty2) | 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 | ||
28 | datatype rator | datatype rator |
29 | = Add of ty | = Add of ty |
# | Line 46 | Line 56 |
56 | | RoundToInt | | RoundToInt |
57 | | CeilToInt | | CeilToInt |
58 | | FloorToInt | | FloorToInt |
59 | | Kernel of Kernel.kernel | |
60 | | LoadImage of ImageInfo.info | | LoadImage of ImageInfo.info |
61 | | Inside | | Inside |
62 | | Field of FieldDef.field_def | | Field of FieldDef.field_def |
63 | | AddField | |
64 | | ScaleField | |
65 | | NegField | |
66 | | DiffField | |
67 | | Probe | | Probe |
68 | | Transform of ImageInfo.info | | Transform of ImageInfo.info |
69 | ||
# | Line 82 | Line 97 |
97 | | arity RoundToInt = 1 | | arity RoundToInt = 1 |
98 | | arity CeilToInt = 1 | | arity CeilToInt = 1 |
99 | | arity FloorToInt = 1 | | arity FloorToInt = 1 |
100 | | arity (Kernel _) = 0 | |
101 | | arity (LoadImage _) = 1 | | arity (LoadImage _) = 1 |
102 | | arity Inside = 2 | | arity Inside = 2 |
103 | | arity (Field _) = 0 | | arity (Field _) = 0 |
104 | | arity AddField = 2 | |
105 | | arity ScaleField = 2 | |
106 | | arity NegField = 1 | |
107 | | arity DiffField = 1 | |
108 | | arity Probe = 2 | | arity Probe = 2 |
109 | | arity (Transform _) = 1 | | arity (Transform _) = 1 |
110 | ||
# | Line 118 | Line 138 |
138 | | same (RoundToInt, RoundToInt) = true | | same (RoundToInt, RoundToInt) = true |
139 | | same (CeilToInt, CeilToInt) = true | | same (CeilToInt, CeilToInt) = true |
140 | | same (FloorToInt, FloorToInt) = true | | same (FloorToInt, FloorToInt) = true |
141 | | same (Kernel a, Kernel b) = Kernel.same(a, b) | |
142 | | same (LoadImage a, LoadImage b) = ImageInfo.same(a, b) | | same (LoadImage a, LoadImage b) = ImageInfo.same(a, b) |
143 | | same (Inside, Inside) = true | | same (Inside, Inside) = true |
144 | | same (Field a, Field b) = FieldDef.same(a, b) | | same (Field a, Field b) = FieldDef.same(a, b) |
145 | | same (AddField, AddField) = true | |
146 | | same (ScaleField, ScaleField) = true | |
147 | | same (NegField, NegField) = true | |
148 | | same (DiffField, DiffField) = true | |
149 | | same (Probe, Probe) = true | | same (Probe, Probe) = true |
150 | | same (Transform a, Transform b) = ImageInfo.same(a, b) | | same (Transform a, Transform b) = ImageInfo.same(a, b) |
151 | | same _ = false | | same _ = false |
# | Line 155 | Line 180 |
180 | | hash RoundToInt = 0w109 | | hash RoundToInt = 0w109 |
181 | | hash CeilToInt = 0w113 | | hash CeilToInt = 0w113 |
182 | | hash FloorToInt = 0w127 | | hash FloorToInt = 0w127 |
183 | | hash (LoadImage a) = 0w131 + ImageInfo.hash a | | hash (Kernel a) = 0w131 + Kernel.hash a |
184 | | hash Inside = 0w137 | | hash (LoadImage a) = 0w137 + ImageInfo.hash a |
185 | | hash (Field a) = 0w139 + FieldDef.hash a | | hash Inside = 0w139 |
186 | | hash Probe = 0w149 | | hash (Field a) = 0w149 + FieldDef.hash a |
187 | | hash (Transform a) = 0w151 + ImageInfo.hash a | | 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 | ||
194 | fun toString (Add a) = concat["Add(", tyToString a, ")"] | fun toString (Add a) = concat["Add(", tyToString a, ")"] |
195 | | toString (Sub a) = concat["Sub(", tyToString a, ")"] | | toString (Sub a) = concat["Sub(", tyToString a, ")"] |
# | Line 191 | Line 221 |
221 | | toString RoundToInt = "RoundToInt" | | toString RoundToInt = "RoundToInt" |
222 | | toString CeilToInt = "CeilToInt" | | toString CeilToInt = "CeilToInt" |
223 | | toString FloorToInt = "FloorToInt" | | toString FloorToInt = "FloorToInt" |
224 | | toString (Kernel a) = concat["Kernel(", Kernel.toString a, ")"] | |
225 | | toString (LoadImage a) = concat["LoadImage(", ImageInfo.toString a, ")"] | | toString (LoadImage a) = concat["LoadImage(", ImageInfo.toString a, ")"] |
226 | | toString Inside = "Inside" | | toString Inside = "Inside" |
227 | | toString (Field a) = concat["Field(", FieldDef.toString a, ")"] | | toString (Field a) = concat["Field(", FieldDef.toString a, ")"] |
228 | | toString AddField = "AddField" | |
229 | | toString ScaleField = "ScaleField" | |
230 | | toString NegField = "NegField" | |
231 | | toString DiffField = "DiffField" | |
232 | | toString Probe = "Probe" | | toString Probe = "Probe" |
233 | | toString (Transform a) = concat["Transform(", ImageInfo.toString a, ")"] | | toString (Transform a) = concat["Transform(", ImageInfo.toString a, ")"] |
234 | ||
235 | end | end |
236 | ||
237 | structure HighIL = SSAFn(HighOps) | structure HighIL = SSAFn(HighOps) |