SCM Repository
Annotation of /trunk/src/compiler/IL/high-il.sml
Parent Directory
|
Revision Log
Revision 180 - (view) (download)
1 : | jhr | 166 | (* high-il.sml |
2 : | * | ||
3 : | * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) | ||
4 : | * All rights reserved. | ||
5 : | * | ||
6 : | * High-level version of the Diderot IL. | ||
7 : | *) | ||
8 : | |||
9 : | structure HighOps = | ||
10 : | struct | ||
11 : | |||
12 : | jhr | 180 | type ty = BoolTy | StringTy | IntTy | TensorTy of int list |
13 : | jhr | 166 | |
14 : | fun sameTy (ty1 : ty, ty2) = (ty1 = ty2) | ||
15 : | |||
16 : | datatype rator | ||
17 : | = Add of ty | Sub of ty (* type-indexed arithmetic operations *) | ||
18 : | | Mul of ty | Div of ty | ||
19 : | | Neg of ty | ||
20 : | jhr | 180 | | LT of ty | LTE of ty |
21 : | | EQ of ty | NEQ of ty | ||
22 : | | GT of ty | GTE of ty | ||
23 : | jhr | 166 | | Dot of ty | Cross | Norm of ty (* vector operations *) |
24 : | | Scale of ty (* scalar/tensor multiplication *) | ||
25 : | | CL (* linear anisotropy measure *) | ||
26 : | | PrincipleEvec (* principle eigenvector *) | ||
27 : | | Subscript of ty | ||
28 : | | Max | Min | ||
29 : | | Sin | Cos | ||
30 : | | Pow | ||
31 : | jhr | 180 | | Not (* boolean negation *) |
32 : | jhr | 166 | (* conversions *) |
33 : | | IntToReal | ||
34 : | | TruncToInt | ||
35 : | | RoundToInt | ||
36 : | | CeilToInt | ||
37 : | | FloorToInt | ||
38 : | (* image/field operations *) | ||
39 : | | LoadImage of ImageInfo.info (* image-file loading *) | ||
40 : | | Inside | ||
41 : | | Field of FieldDef.field_def | ||
42 : | | Probe | ||
43 : | | Transform of ImageInfo.info (* transform to image-space *) | ||
44 : | |||
45 : | fun arity (Add _) = 2 | ||
46 : | | arity (Sub _) = 2 | ||
47 : | | arity (Mul _) = 2 | ||
48 : | | arity (Div _) = 2 | ||
49 : | | arity (Neg _) = 1 | ||
50 : | jhr | 180 | | arity (LT _) = 2 |
51 : | | arity (LTE _) = 2 | ||
52 : | | arity (EQ _) = 2 | ||
53 : | | arity (NEQ _) = 2 | ||
54 : | | arity (GT _) = 2 | ||
55 : | | arity (GTE _) = 2 | ||
56 : | jhr | 166 | | arity (Dot _) = 2 |
57 : | | arity Cross = 2 | ||
58 : | | arity (Norm _) = 1 | ||
59 : | | arity (Scale _) = 2 | ||
60 : | | arity CL = 2 | ||
61 : | | arity PrincipleEvec = 1 | ||
62 : | | arity (Subscript _) = 2 | ||
63 : | | arity Max = 1 | ||
64 : | | arity Min = 1 | ||
65 : | | arity Sin = 1 | ||
66 : | | arity Cos = 1 | ||
67 : | | arity Pow = 2 | ||
68 : | jhr | 180 | | arity Not = 1 |
69 : | jhr | 166 | | arity IntToReal = 1 |
70 : | | arity TruncToInt = 1 | ||
71 : | | arity RoundToInt = 1 | ||
72 : | | arity CeilToInt = 1 | ||
73 : | | arity FloorToInt = 1 | ||
74 : | | arity (LoadImage _) = 1 | ||
75 : | | arity Inside = 2 | ||
76 : | | arity (Field _) = 0 | ||
77 : | | arity Probe = 2 | ||
78 : | | arity (Transform _) = 1 | ||
79 : | |||
80 : | fun same (Add ty1, Add ty2) = sameTy(ty1, ty2) | ||
81 : | | same (Sub ty1, Sub ty2) = sameTy(ty1, ty2) | ||
82 : | | same (Mul ty1, Mul ty2) = sameTy(ty1, ty2) | ||
83 : | | same (Div ty1, Div ty2) = sameTy(ty1, ty2) | ||
84 : | | same (Neg ty1, Neg ty2) = sameTy(ty1, ty2) | ||
85 : | jhr | 180 | | same (LT ty1, LT ty2) = sameTy(ty1, ty2) |
86 : | | same (LTE ty1, LTE ty2) = sameTy(ty1, ty2) | ||
87 : | | same (EQ ty1, EQ ty2) = sameTy(ty1, ty2) | ||
88 : | | same (NEQ ty1, NEQ ty2) = sameTy(ty1, ty2) | ||
89 : | | same (GT ty1, GT ty2) = sameTy(ty1, ty2) | ||
90 : | | same (GTE ty1, GTE ty2) = sameTy(ty1, ty2) | ||
91 : | jhr | 166 | | same (Dot ty1, Dot ty2) = sameTy(ty1, ty2) |
92 : | | same (Cross, Cross) = true | ||
93 : | | same (Norm ty1, Norm ty2) = sameTy(ty1, ty2) | ||
94 : | | same (Scale ty1, Scale ty2) = sameTy(ty1, ty2) | ||
95 : | | same (CL, CL) = true | ||
96 : | | same (PrincipleEvec, PrincipleEvec) = true | ||
97 : | | same (Subscript ty1, Subscript ty2) = sameTy(ty1, ty2) | ||
98 : | | same (Max, Max) = true | ||
99 : | | same (Min, Min) = true | ||
100 : | | same (Sin, Sin) = true | ||
101 : | | same (Cos, Cos) = true | ||
102 : | | same (Pow, Pow) = true | ||
103 : | jhr | 180 | | same (Not, Not) = true |
104 : | jhr | 166 | | same (IntToReal, IntToReal) = true |
105 : | | same (TruncToInt, TruncToInt) = true | ||
106 : | | same (RoundToInt, RoundToInt) = true | ||
107 : | | same (CeilToInt, CeilToInt) = true | ||
108 : | | same (FloorToInt, FloorToInt) = true | ||
109 : | | same (LoadImage img1, LoadImage img2) = ImageInfo.same(img1, img2) | ||
110 : | | same (Inside, Inside) = true | ||
111 : | | same (Field fld1, Field fld2) = FieldDef.same(fld1, fld2) | ||
112 : | | same (Probe, Probe) = true | ||
113 : | | same (Transform img1, Transform img2) = ImageInfo.same(img1, img2) | ||
114 : | | same _ = false | ||
115 : | |||
116 : | fun hash (Add ty) = 0w11 + hashTy ty | ||
117 : | | hash (Sub ty) = 0w13 + hashTy ty | ||
118 : | | hash (Mul ty) = 0w17 + hashTy ty | ||
119 : | | hash (Div ty) = 0w19 + hashTy ty | ||
120 : | | hash (Neg ty) = 0w23 + hashTy ty | ||
121 : | | hash (Dot ty) = 0w29 + hashTy ty | ||
122 : | | hash Cross = 0w31 | ||
123 : | | hash (Norm ty) = 0w37 + hashTy ty | ||
124 : | | hash (Scale ty) = 0w41 + hashTy ty | ||
125 : | | hash CL = 0w43 | ||
126 : | | hash PrincipleEvec = 0w47 | ||
127 : | | hash (Subscript ty) = 0w53 + hashTy ty | ||
128 : | | hash Max = 0w59 | ||
129 : | | hash Min = 0w61 | ||
130 : | | hash Sin = 0w67 | ||
131 : | | hash Cos = 0w71 | ||
132 : | | hash Pow = 0w73 | ||
133 : | | hash IntToReal = 0w79 | ||
134 : | | hash TruncToInt = 0w83 | ||
135 : | | hash RoundToInt = 0w89 | ||
136 : | | hash CeilToInt = 0w97 | ||
137 : | | hash FloorToInt = 0w101 | ||
138 : | | hash (LoadImage img) = 0w103 + ImageInfo.hash img | ||
139 : | | hash Inside = 0w107 | ||
140 : | | hash (Field fld) = 0w109 + FieldDef.hash fld | ||
141 : | | hash Probe = 0w113 | ||
142 : | | hash (Transform img) = 0w127 + ImageInfo.hash img | ||
143 : | |||
144 : | val toString : rator -> string | ||
145 : | |||
146 : | end | ||
147 : | |||
148 : | structure HighIL = SSAFn(HighOps) |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |