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

SCM Repository

[diderot] Annotation of /trunk/src/compiler/mid-il/mid-il.sml
ViewVC logotype

Annotation of /trunk/src/compiler/mid-il/mid-il.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 391 - (view) (download)

1 : jhr 287 (* mid-il.sml
2 :     *
3 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *
6 :     * Middle-level version of the Diderot IL.
7 :     *
8 :     * Note: this file is generated from gen/mid-il.spec and gen/mid-il.in.
9 :     *)
10 :    
11 :     structure MidOps =
12 :     struct
13 :    
14 : jhr 391 type ty = MidILTypes.ty
15 : jhr 287
16 : jhr 391 val samety = MidILTypes.same
17 :     val hashty = MidILTypes.hash
18 :     val tyToString = MidILTypes.toString
19 : jhr 328
20 : jhr 332 fun sameint (i1 : int, i2) = (i1 = i2)
21 :     fun hashint i = Word.fromInt i
22 :     fun intToString i = Int.toString i
23 :    
24 : jhr 287 fun samestring (s1 : string, s2) = (s1 = s2)
25 :     val hashstring = HashString.hashString
26 :     fun stringToString s = String.concat["\"", s, "\""]
27 :    
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 : jhr 333 | Not
41 :     | Max
42 :     | Min
43 :     | Sin
44 :     | Cos
45 :     | Pow
46 : jhr 349 | Dot of int
47 : jhr 287 | Cross
48 : jhr 349 | Select of int * int
49 :     | Norm of int
50 :     | Scale of int
51 :     | InvScale of int
52 : jhr 287 | CL
53 :     | PrincipleEvec of ty
54 :     | Subscript of ty
55 : jhr 333 | Floor of int
56 : jhr 287 | IntToReal
57 : jhr 333 | TruncToInt of int
58 :     | RoundToInt of int
59 :     | CeilToInt of int
60 :     | FloorToInt of int
61 : jhr 287 | VoxelAddress of ImageInfo.info
62 :     | LoadVoxels of RawTypes.ty * int
63 :     | Transform of ImageInfo.info
64 : jhr 328 | EvalKernel of int * Kernel.kernel * int
65 : jhr 287 | LoadImage of ImageInfo.info
66 : jhr 349 | Inside of ImageInfo.info
67 : jhr 287 | Input of string
68 :     | InputWithDefault of string
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 : jhr 333 | arity Not = 1
82 :     | arity Max = 2
83 :     | arity Min = 2
84 :     | arity Sin = 1
85 :     | arity Cos = 1
86 :     | arity Pow = 2
87 : jhr 287 | arity (Dot _) = 2
88 :     | arity Cross = 2
89 :     | arity (Select _) = 1
90 :     | arity (Norm _) = 1
91 :     | arity (Scale _) = 2
92 :     | arity (InvScale _) = 2
93 :     | arity CL = 1
94 :     | arity (PrincipleEvec _) = 2
95 :     | arity (Subscript _) = 2
96 : jhr 333 | arity (Floor _) = 1
97 : jhr 287 | arity IntToReal = 1
98 : jhr 333 | arity (TruncToInt _) = 1
99 :     | arity (RoundToInt _) = 1
100 :     | arity (CeilToInt _) = 1
101 :     | arity (FloorToInt _) = 1
102 : jhr 287 | arity (VoxelAddress _) = ~1
103 :     | arity (LoadVoxels _) = 1
104 :     | arity (Transform _) = 1
105 : jhr 328 | arity (EvalKernel _) = 1
106 : jhr 287 | arity (LoadImage _) = 0
107 : jhr 349 | arity (Inside _) = 1
108 : jhr 287 | arity (Input _) = 0
109 :     | arity (InputWithDefault _) = 1
110 :    
111 :     fun same (Add(a0), Add(b0)) = samety(a0, b0)
112 :     | same (Sub(a0), Sub(b0)) = samety(a0, b0)
113 :     | same (Mul(a0), Mul(b0)) = samety(a0, b0)
114 :     | same (Div(a0), Div(b0)) = samety(a0, b0)
115 :     | same (Neg(a0), Neg(b0)) = samety(a0, b0)
116 :     | same (LT(a0), LT(b0)) = samety(a0, b0)
117 :     | same (LTE(a0), LTE(b0)) = samety(a0, b0)
118 :     | same (EQ(a0), EQ(b0)) = samety(a0, b0)
119 :     | same (NEQ(a0), NEQ(b0)) = samety(a0, b0)
120 :     | same (GT(a0), GT(b0)) = samety(a0, b0)
121 :     | same (GTE(a0), GTE(b0)) = samety(a0, b0)
122 : jhr 333 | same (Not, Not) = true
123 :     | same (Max, Max) = true
124 :     | same (Min, Min) = true
125 :     | same (Sin, Sin) = true
126 :     | same (Cos, Cos) = true
127 :     | same (Pow, Pow) = true
128 : jhr 349 | same (Dot(a0), Dot(b0)) = sameint(a0, b0)
129 : jhr 287 | same (Cross, Cross) = true
130 : jhr 349 | same (Select(a0,a1), Select(b0,b1)) = sameint(a0, b0) andalso sameint(a1, b1)
131 :     | same (Norm(a0), Norm(b0)) = sameint(a0, b0)
132 :     | same (Scale(a0), Scale(b0)) = sameint(a0, b0)
133 :     | same (InvScale(a0), InvScale(b0)) = sameint(a0, b0)
134 : jhr 287 | same (CL, CL) = true
135 :     | same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0)
136 :     | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)
137 : jhr 333 | same (Floor(a0), Floor(b0)) = sameint(a0, b0)
138 : jhr 287 | same (IntToReal, IntToReal) = true
139 : jhr 333 | same (TruncToInt(a0), TruncToInt(b0)) = sameint(a0, b0)
140 :     | same (RoundToInt(a0), RoundToInt(b0)) = sameint(a0, b0)
141 :     | same (CeilToInt(a0), CeilToInt(b0)) = sameint(a0, b0)
142 :     | same (FloorToInt(a0), FloorToInt(b0)) = sameint(a0, b0)
143 : jhr 287 | same (VoxelAddress(a0), VoxelAddress(b0)) = ImageInfo.same(a0, b0)
144 :     | same (LoadVoxels(a0,a1), LoadVoxels(b0,b1)) = RawTypes.same(a0, b0) andalso sameint(a1, b1)
145 :     | same (Transform(a0), Transform(b0)) = ImageInfo.same(a0, b0)
146 : jhr 328 | same (EvalKernel(a0,a1,a2), EvalKernel(b0,b1,b2)) = sameint(a0, b0) andalso Kernel.same(a1, b1) andalso sameint(a2, b2)
147 : jhr 287 | same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0)
148 : jhr 349 | same (Inside(a0), Inside(b0)) = ImageInfo.same(a0, b0)
149 : jhr 287 | same (Input(a0), Input(b0)) = samestring(a0, b0)
150 :     | same (InputWithDefault(a0), InputWithDefault(b0)) = samestring(a0, b0)
151 :     | same _ = false
152 :    
153 :     fun hash (Add(a0)) = 0w3 + hashty a0
154 :     | hash (Sub(a0)) = 0w5 + hashty a0
155 :     | hash (Mul(a0)) = 0w7 + hashty a0
156 :     | hash (Div(a0)) = 0w11 + hashty a0
157 :     | hash (Neg(a0)) = 0w13 + hashty a0
158 :     | hash (LT(a0)) = 0w17 + hashty a0
159 :     | hash (LTE(a0)) = 0w19 + hashty a0
160 :     | hash (EQ(a0)) = 0w23 + hashty a0
161 :     | hash (NEQ(a0)) = 0w29 + hashty a0
162 :     | hash (GT(a0)) = 0w31 + hashty a0
163 :     | hash (GTE(a0)) = 0w37 + hashty a0
164 : jhr 333 | hash Not = 0w41
165 :     | hash Max = 0w43
166 :     | hash Min = 0w47
167 :     | hash Sin = 0w53
168 :     | hash Cos = 0w59
169 :     | hash Pow = 0w61
170 : jhr 349 | hash (Dot(a0)) = 0w67 + hashint a0
171 : jhr 333 | hash Cross = 0w71
172 : jhr 349 | hash (Select(a0,a1)) = 0w73 + hashint a0 + hashint a1
173 :     | hash (Norm(a0)) = 0w79 + hashint a0
174 :     | hash (Scale(a0)) = 0w83 + hashint a0
175 :     | hash (InvScale(a0)) = 0w89 + hashint a0
176 : jhr 333 | hash CL = 0w97
177 :     | hash (PrincipleEvec(a0)) = 0w101 + hashty a0
178 :     | hash (Subscript(a0)) = 0w103 + hashty a0
179 :     | hash (Floor(a0)) = 0w107 + hashint a0
180 :     | hash IntToReal = 0w109
181 :     | hash (TruncToInt(a0)) = 0w113 + hashint a0
182 :     | hash (RoundToInt(a0)) = 0w127 + hashint a0
183 :     | hash (CeilToInt(a0)) = 0w131 + hashint a0
184 :     | hash (FloorToInt(a0)) = 0w137 + hashint a0
185 :     | hash (VoxelAddress(a0)) = 0w139 + ImageInfo.hash a0
186 :     | hash (LoadVoxels(a0,a1)) = 0w149 + RawTypes.hash a0 + hashint a1
187 :     | hash (Transform(a0)) = 0w151 + ImageInfo.hash a0
188 :     | hash (EvalKernel(a0,a1,a2)) = 0w157 + hashint a0 + Kernel.hash a1 + hashint a2
189 :     | hash (LoadImage(a0)) = 0w163 + ImageInfo.hash a0
190 : jhr 349 | hash (Inside(a0)) = 0w167 + ImageInfo.hash a0
191 : jhr 333 | hash (Input(a0)) = 0w173 + hashstring a0
192 :     | hash (InputWithDefault(a0)) = 0w179 + hashstring a0
193 : jhr 287
194 :     fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]
195 :     | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]
196 :     | toString (Mul(a0)) = concat["Mul<", tyToString a0, ">"]
197 :     | toString (Div(a0)) = concat["Div<", tyToString a0, ">"]
198 :     | toString (Neg(a0)) = concat["Neg<", tyToString a0, ">"]
199 :     | toString (LT(a0)) = concat["LT<", tyToString a0, ">"]
200 :     | toString (LTE(a0)) = concat["LTE<", tyToString a0, ">"]
201 :     | toString (EQ(a0)) = concat["EQ<", tyToString a0, ">"]
202 :     | toString (NEQ(a0)) = concat["NEQ<", tyToString a0, ">"]
203 :     | toString (GT(a0)) = concat["GT<", tyToString a0, ">"]
204 :     | toString (GTE(a0)) = concat["GTE<", tyToString a0, ">"]
205 : jhr 333 | toString Not = "Not"
206 :     | toString Max = "Max"
207 :     | toString Min = "Min"
208 :     | toString Sin = "Sin"
209 :     | toString Cos = "Cos"
210 :     | toString Pow = "Pow"
211 : jhr 349 | toString (Dot(a0)) = concat["Dot<", intToString a0, ">"]
212 : jhr 287 | toString Cross = "Cross"
213 : jhr 349 | toString (Select(a0,a1)) = concat["Select<", intToString a0, ",", intToString a1, ">"]
214 :     | toString (Norm(a0)) = concat["Norm<", intToString a0, ">"]
215 :     | toString (Scale(a0)) = concat["Scale<", intToString a0, ">"]
216 :     | toString (InvScale(a0)) = concat["InvScale<", intToString a0, ">"]
217 : jhr 287 | toString CL = "CL"
218 :     | toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"]
219 :     | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]
220 : jhr 333 | toString (Floor(a0)) = concat["Floor<", intToString a0, ">"]
221 : jhr 287 | toString IntToReal = "IntToReal"
222 : jhr 333 | toString (TruncToInt(a0)) = concat["TruncToInt<", intToString a0, ">"]
223 :     | toString (RoundToInt(a0)) = concat["RoundToInt<", intToString a0, ">"]
224 :     | toString (CeilToInt(a0)) = concat["CeilToInt<", intToString a0, ">"]
225 :     | toString (FloorToInt(a0)) = concat["FloorToInt<", intToString a0, ">"]
226 : jhr 287 | toString (VoxelAddress(a0)) = concat["VoxelAddress<", ImageInfo.toString a0, ">"]
227 : jhr 332 | toString (LoadVoxels(a0,a1)) = concat["LoadVoxels<", RawTypes.toString a0, ",", intToString a1, ">"]
228 : jhr 287 | toString (Transform(a0)) = concat["Transform<", ImageInfo.toString a0, ">"]
229 : jhr 332 | toString (EvalKernel(a0,a1,a2)) = concat["EvalKernel<", intToString a0, ",", Kernel.toString a1, ",", intToString a2, ">"]
230 : jhr 287 | toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"]
231 : jhr 349 | toString (Inside(a0)) = concat["Inside<", ImageInfo.toString a0, ">"]
232 : jhr 287 | toString (Input(a0)) = concat["Input<", stringToString a0, ">"]
233 :     | toString (InputWithDefault(a0)) = concat["InputWithDefault<", stringToString a0, ">"]
234 :    
235 :     end
236 :    
237 :     structure MidIL = SSAFn(MidOps)

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