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

SCM Repository

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

Annotation of /branches/vis12/src/compiler/mid-il/mid-il.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 314 - (view) (download)
Original Path: trunk/src/compiler/mid-il/mid-il.sml

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

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