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

SCM Repository

[diderot] Annotation of /branches/charisee/src/compiler/low-il/low-il.sml
ViewVC logotype

Annotation of /branches/charisee/src/compiler/low-il/low-il.sml

Parent Directory Parent Directory | Revision Log Revision Log


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

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

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