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 333 - (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 :     datatype ty = BoolTy | StringTy | IntTy | VecTy of int
15 :    
16 : jhr 328 val realTy = VecTy 0
17 :    
18 : jhr 287 fun samety (ty1 : ty, ty2) = (ty1 = ty2)
19 :     fun hashty BoolTy = 0w1
20 :     | hashty StringTy = 0w2
21 :     | hashty IntTy = 0w3
22 :     | hashty (VecTy d) = Word.fromInt d + 0w4
23 :     fun tyToString BoolTy = "bool"
24 :     | tyToString StringTy = "string"
25 :     | tyToString IntTy = "int"
26 :     | tyToString (VecTy 0) = "real"
27 :     | tyToString (VecTy d) = "vec" ^ Int.toString d
28 :    
29 : jhr 332 fun sameint (i1 : int, i2) = (i1 = i2)
30 :     fun hashint i = Word.fromInt i
31 :     fun intToString i = Int.toString i
32 :    
33 : jhr 287 fun samestring (s1 : string, s2) = (s1 = s2)
34 :     val hashstring = HashString.hashString
35 :     fun stringToString s = String.concat["\"", s, "\""]
36 :    
37 :     datatype rator
38 :     = Add of ty
39 :     | Sub of ty
40 :     | Mul of ty
41 :     | Div of ty
42 :     | Neg of ty
43 :     | LT of ty
44 :     | LTE of ty
45 :     | EQ of ty
46 :     | NEQ of ty
47 :     | GT of ty
48 :     | GTE of ty
49 : jhr 333 | Not
50 :     | Max
51 :     | Min
52 :     | Sin
53 :     | Cos
54 :     | Pow
55 : jhr 287 | Dot of ty
56 :     | Cross
57 :     | Select of int
58 :     | Norm of ty
59 :     | Scale of ty
60 :     | InvScale of ty
61 :     | CL
62 :     | PrincipleEvec of ty
63 :     | Subscript of ty
64 : jhr 333 | Floor of int
65 : jhr 287 | IntToReal
66 : jhr 333 | TruncToInt of int
67 :     | RoundToInt of int
68 :     | CeilToInt of int
69 :     | FloorToInt of int
70 : jhr 287 | VoxelAddress of ImageInfo.info
71 :     | LoadVoxels of RawTypes.ty * int
72 :     | Transform of ImageInfo.info
73 : jhr 328 | EvalKernel of int * Kernel.kernel * int
74 : jhr 287 | LoadImage of ImageInfo.info
75 :     | Inside
76 :     | Input of string
77 :     | InputWithDefault of string
78 :    
79 :     fun arity (Add _) = 2
80 :     | arity (Sub _) = 2
81 :     | arity (Mul _) = 2
82 :     | arity (Div _) = 2
83 :     | arity (Neg _) = 1
84 :     | arity (LT _) = 2
85 :     | arity (LTE _) = 2
86 :     | arity (EQ _) = 2
87 :     | arity (NEQ _) = 2
88 :     | arity (GT _) = 2
89 :     | arity (GTE _) = 2
90 : jhr 333 | arity Not = 1
91 :     | arity Max = 2
92 :     | arity Min = 2
93 :     | arity Sin = 1
94 :     | arity Cos = 1
95 :     | arity Pow = 2
96 : jhr 287 | arity (Dot _) = 2
97 :     | arity Cross = 2
98 :     | arity (Select _) = 1
99 :     | arity (Norm _) = 1
100 :     | arity (Scale _) = 2
101 :     | arity (InvScale _) = 2
102 :     | arity CL = 1
103 :     | arity (PrincipleEvec _) = 2
104 :     | arity (Subscript _) = 2
105 : jhr 333 | arity (Floor _) = 1
106 : jhr 287 | arity IntToReal = 1
107 : jhr 333 | arity (TruncToInt _) = 1
108 :     | arity (RoundToInt _) = 1
109 :     | arity (CeilToInt _) = 1
110 :     | arity (FloorToInt _) = 1
111 : jhr 287 | arity (VoxelAddress _) = ~1
112 :     | arity (LoadVoxels _) = 1
113 :     | arity (Transform _) = 1
114 : jhr 328 | arity (EvalKernel _) = 1
115 : jhr 287 | arity (LoadImage _) = 0
116 :     | arity Inside = 2
117 :     | arity (Input _) = 0
118 :     | arity (InputWithDefault _) = 1
119 :    
120 :     fun same (Add(a0), Add(b0)) = samety(a0, b0)
121 :     | same (Sub(a0), Sub(b0)) = samety(a0, b0)
122 :     | same (Mul(a0), Mul(b0)) = samety(a0, b0)
123 :     | same (Div(a0), Div(b0)) = samety(a0, b0)
124 :     | same (Neg(a0), Neg(b0)) = samety(a0, b0)
125 :     | same (LT(a0), LT(b0)) = samety(a0, b0)
126 :     | same (LTE(a0), LTE(b0)) = samety(a0, b0)
127 :     | same (EQ(a0), EQ(b0)) = samety(a0, b0)
128 :     | same (NEQ(a0), NEQ(b0)) = samety(a0, b0)
129 :     | same (GT(a0), GT(b0)) = samety(a0, b0)
130 :     | same (GTE(a0), GTE(b0)) = samety(a0, b0)
131 : jhr 333 | same (Not, Not) = true
132 :     | 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 287 | same (Dot(a0), Dot(b0)) = samety(a0, b0)
138 :     | same (Cross, Cross) = true
139 :     | same (Select(a0), Select(b0)) = sameint(a0, b0)
140 :     | same (Norm(a0), Norm(b0)) = samety(a0, b0)
141 :     | same (Scale(a0), Scale(b0)) = samety(a0, b0)
142 :     | same (InvScale(a0), InvScale(b0)) = samety(a0, b0)
143 :     | same (CL, CL) = true
144 :     | same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0)
145 :     | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)
146 : jhr 333 | same (Floor(a0), Floor(b0)) = sameint(a0, b0)
147 : jhr 287 | same (IntToReal, IntToReal) = true
148 : jhr 333 | same (TruncToInt(a0), TruncToInt(b0)) = sameint(a0, b0)
149 :     | same (RoundToInt(a0), RoundToInt(b0)) = sameint(a0, b0)
150 :     | same (CeilToInt(a0), CeilToInt(b0)) = sameint(a0, b0)
151 :     | same (FloorToInt(a0), FloorToInt(b0)) = sameint(a0, b0)
152 : jhr 287 | same (VoxelAddress(a0), VoxelAddress(b0)) = ImageInfo.same(a0, b0)
153 :     | same (LoadVoxels(a0,a1), LoadVoxels(b0,b1)) = RawTypes.same(a0, b0) andalso sameint(a1, b1)
154 :     | same (Transform(a0), Transform(b0)) = ImageInfo.same(a0, b0)
155 : jhr 328 | same (EvalKernel(a0,a1,a2), EvalKernel(b0,b1,b2)) = sameint(a0, b0) andalso Kernel.same(a1, b1) andalso sameint(a2, b2)
156 : jhr 287 | same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0)
157 :     | same (Inside, Inside) = true
158 :     | same (Input(a0), Input(b0)) = samestring(a0, b0)
159 :     | same (InputWithDefault(a0), InputWithDefault(b0)) = samestring(a0, b0)
160 :     | same _ = false
161 :    
162 :     fun hash (Add(a0)) = 0w3 + hashty a0
163 :     | hash (Sub(a0)) = 0w5 + hashty a0
164 :     | hash (Mul(a0)) = 0w7 + hashty a0
165 :     | hash (Div(a0)) = 0w11 + hashty a0
166 :     | hash (Neg(a0)) = 0w13 + hashty a0
167 :     | hash (LT(a0)) = 0w17 + hashty a0
168 :     | hash (LTE(a0)) = 0w19 + hashty a0
169 :     | hash (EQ(a0)) = 0w23 + hashty a0
170 :     | hash (NEQ(a0)) = 0w29 + hashty a0
171 :     | hash (GT(a0)) = 0w31 + hashty a0
172 :     | hash (GTE(a0)) = 0w37 + hashty a0
173 : jhr 333 | hash Not = 0w41
174 :     | hash Max = 0w43
175 :     | hash Min = 0w47
176 :     | hash Sin = 0w53
177 :     | hash Cos = 0w59
178 :     | hash Pow = 0w61
179 :     | hash (Dot(a0)) = 0w67 + hashty a0
180 :     | hash Cross = 0w71
181 :     | hash (Select(a0)) = 0w73 + hashint a0
182 :     | hash (Norm(a0)) = 0w79 + hashty a0
183 :     | hash (Scale(a0)) = 0w83 + hashty a0
184 :     | hash (InvScale(a0)) = 0w89 + hashty a0
185 :     | hash CL = 0w97
186 :     | hash (PrincipleEvec(a0)) = 0w101 + hashty a0
187 :     | hash (Subscript(a0)) = 0w103 + hashty a0
188 :     | hash (Floor(a0)) = 0w107 + hashint a0
189 :     | hash IntToReal = 0w109
190 :     | hash (TruncToInt(a0)) = 0w113 + hashint a0
191 :     | hash (RoundToInt(a0)) = 0w127 + hashint a0
192 :     | hash (CeilToInt(a0)) = 0w131 + hashint a0
193 :     | hash (FloorToInt(a0)) = 0w137 + hashint a0
194 :     | hash (VoxelAddress(a0)) = 0w139 + ImageInfo.hash a0
195 :     | hash (LoadVoxels(a0,a1)) = 0w149 + RawTypes.hash a0 + hashint a1
196 :     | hash (Transform(a0)) = 0w151 + ImageInfo.hash a0
197 :     | hash (EvalKernel(a0,a1,a2)) = 0w157 + hashint a0 + Kernel.hash a1 + hashint a2
198 :     | hash (LoadImage(a0)) = 0w163 + ImageInfo.hash a0
199 :     | hash Inside = 0w167
200 :     | hash (Input(a0)) = 0w173 + hashstring a0
201 :     | hash (InputWithDefault(a0)) = 0w179 + hashstring a0
202 : jhr 287
203 :     fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]
204 :     | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]
205 :     | toString (Mul(a0)) = concat["Mul<", tyToString a0, ">"]
206 :     | toString (Div(a0)) = concat["Div<", tyToString a0, ">"]
207 :     | toString (Neg(a0)) = concat["Neg<", tyToString a0, ">"]
208 :     | toString (LT(a0)) = concat["LT<", tyToString a0, ">"]
209 :     | toString (LTE(a0)) = concat["LTE<", tyToString a0, ">"]
210 :     | toString (EQ(a0)) = concat["EQ<", tyToString a0, ">"]
211 :     | toString (NEQ(a0)) = concat["NEQ<", tyToString a0, ">"]
212 :     | toString (GT(a0)) = concat["GT<", tyToString a0, ">"]
213 :     | toString (GTE(a0)) = concat["GTE<", tyToString a0, ">"]
214 : jhr 333 | toString Not = "Not"
215 :     | toString Max = "Max"
216 :     | toString Min = "Min"
217 :     | toString Sin = "Sin"
218 :     | toString Cos = "Cos"
219 :     | toString Pow = "Pow"
220 : jhr 287 | toString (Dot(a0)) = concat["Dot<", tyToString a0, ">"]
221 :     | toString Cross = "Cross"
222 :     | toString (Select(a0)) = concat["Select<", intToString a0, ">"]
223 :     | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]
224 :     | toString (Scale(a0)) = concat["Scale<", tyToString a0, ">"]
225 :     | toString (InvScale(a0)) = concat["InvScale<", tyToString a0, ">"]
226 :     | toString CL = "CL"
227 :     | toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"]
228 :     | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]
229 : jhr 333 | toString (Floor(a0)) = concat["Floor<", intToString a0, ">"]
230 : jhr 287 | toString IntToReal = "IntToReal"
231 : jhr 333 | toString (TruncToInt(a0)) = concat["TruncToInt<", intToString a0, ">"]
232 :     | toString (RoundToInt(a0)) = concat["RoundToInt<", intToString a0, ">"]
233 :     | toString (CeilToInt(a0)) = concat["CeilToInt<", intToString a0, ">"]
234 :     | toString (FloorToInt(a0)) = concat["FloorToInt<", intToString a0, ">"]
235 : jhr 287 | toString (VoxelAddress(a0)) = concat["VoxelAddress<", ImageInfo.toString a0, ">"]
236 : jhr 332 | toString (LoadVoxels(a0,a1)) = concat["LoadVoxels<", RawTypes.toString a0, ",", intToString a1, ">"]
237 : jhr 287 | toString (Transform(a0)) = concat["Transform<", ImageInfo.toString a0, ">"]
238 : jhr 332 | toString (EvalKernel(a0,a1,a2)) = concat["EvalKernel<", intToString a0, ",", Kernel.toString a1, ",", intToString a2, ">"]
239 : jhr 287 | toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"]
240 :     | toString Inside = "Inside"
241 :     | toString (Input(a0)) = concat["Input<", stringToString a0, ">"]
242 :     | toString (InputWithDefault(a0)) = concat["InputWithDefault<", stringToString a0, ">"]
243 :    
244 :     end
245 :    
246 :     structure MidIL = SSAFn(MidOps)

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