SCM Repository
Annotation of /trunk/src/compiler/IL/high-il.sml
Parent Directory
|
Revision Log
Revision 166 - (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 : | type ty = IntTy | TensorTy of int list | ||
13 : | |||
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 : | | Dot of ty | Cross | Norm of ty (* vector operations *) | ||
21 : | | Scale of ty (* scalar/tensor multiplication *) | ||
22 : | | CL (* linear anisotropy measure *) | ||
23 : | | PrincipleEvec (* principle eigenvector *) | ||
24 : | | Subscript of ty | ||
25 : | | Max | Min | ||
26 : | | Sin | Cos | ||
27 : | | Pow | ||
28 : | (* conversions *) | ||
29 : | | IntToReal | ||
30 : | | TruncToInt | ||
31 : | | RoundToInt | ||
32 : | | CeilToInt | ||
33 : | | FloorToInt | ||
34 : | (* image/field operations *) | ||
35 : | | LoadImage of ImageInfo.info (* image-file loading *) | ||
36 : | | Inside | ||
37 : | | Field of FieldDef.field_def | ||
38 : | | Probe | ||
39 : | | Transform of ImageInfo.info (* transform to image-space *) | ||
40 : | |||
41 : | fun arity (Add _) = 2 | ||
42 : | | arity (Sub _) = 2 | ||
43 : | | arity (Mul _) = 2 | ||
44 : | | arity (Div _) = 2 | ||
45 : | | arity (Neg _) = 1 | ||
46 : | | arity (Dot _) = 2 | ||
47 : | | arity Cross = 2 | ||
48 : | | arity (Norm _) = 1 | ||
49 : | | arity (Scale _) = 2 | ||
50 : | | arity CL = 2 | ||
51 : | | arity PrincipleEvec = 1 | ||
52 : | | arity (Subscript _) = 2 | ||
53 : | | arity Max = 1 | ||
54 : | | arity Min = 1 | ||
55 : | | arity Sin = 1 | ||
56 : | | arity Cos = 1 | ||
57 : | | arity Pow = 2 | ||
58 : | | arity IntToReal = 1 | ||
59 : | | arity TruncToInt = 1 | ||
60 : | | arity RoundToInt = 1 | ||
61 : | | arity CeilToInt = 1 | ||
62 : | | arity FloorToInt = 1 | ||
63 : | | arity (LoadImage _) = 1 | ||
64 : | | arity Inside = 2 | ||
65 : | | arity (Field _) = 0 | ||
66 : | | arity Probe = 2 | ||
67 : | | arity (Transform _) = 1 | ||
68 : | |||
69 : | fun same (Add ty1, Add ty2) = sameTy(ty1, ty2) | ||
70 : | | same (Sub ty1, Sub ty2) = sameTy(ty1, ty2) | ||
71 : | | same (Mul ty1, Mul ty2) = sameTy(ty1, ty2) | ||
72 : | | same (Div ty1, Div ty2) = sameTy(ty1, ty2) | ||
73 : | | same (Neg ty1, Neg ty2) = sameTy(ty1, ty2) | ||
74 : | | same (Dot ty1, Dot ty2) = sameTy(ty1, ty2) | ||
75 : | | same (Cross, Cross) = true | ||
76 : | | same (Norm ty1, Norm ty2) = sameTy(ty1, ty2) | ||
77 : | | same (Scale ty1, Scale ty2) = sameTy(ty1, ty2) | ||
78 : | | same (CL, CL) = true | ||
79 : | | same (PrincipleEvec, PrincipleEvec) = true | ||
80 : | | same (Subscript ty1, Subscript ty2) = sameTy(ty1, ty2) | ||
81 : | | same (Max, Max) = true | ||
82 : | | same (Min, Min) = true | ||
83 : | | same (Sin, Sin) = true | ||
84 : | | same (Cos, Cos) = true | ||
85 : | | same (Pow, Pow) = true | ||
86 : | | same (IntToReal, IntToReal) = true | ||
87 : | | same (TruncToInt, TruncToInt) = true | ||
88 : | | same (RoundToInt, RoundToInt) = true | ||
89 : | | same (CeilToInt, CeilToInt) = true | ||
90 : | | same (FloorToInt, FloorToInt) = true | ||
91 : | | same (LoadImage img1, LoadImage img2) = ImageInfo.same(img1, img2) | ||
92 : | | same (Inside, Inside) = true | ||
93 : | | same (Field fld1, Field fld2) = FieldDef.same(fld1, fld2) | ||
94 : | | same (Probe, Probe) = true | ||
95 : | | same (Transform img1, Transform img2) = ImageInfo.same(img1, img2) | ||
96 : | | same _ = false | ||
97 : | |||
98 : | fun hash (Add ty) = 0w11 + hashTy ty | ||
99 : | | hash (Sub ty) = 0w13 + hashTy ty | ||
100 : | | hash (Mul ty) = 0w17 + hashTy ty | ||
101 : | | hash (Div ty) = 0w19 + hashTy ty | ||
102 : | | hash (Neg ty) = 0w23 + hashTy ty | ||
103 : | | hash (Dot ty) = 0w29 + hashTy ty | ||
104 : | | hash Cross = 0w31 | ||
105 : | | hash (Norm ty) = 0w37 + hashTy ty | ||
106 : | | hash (Scale ty) = 0w41 + hashTy ty | ||
107 : | | hash CL = 0w43 | ||
108 : | | hash PrincipleEvec = 0w47 | ||
109 : | | hash (Subscript ty) = 0w53 + hashTy ty | ||
110 : | | hash Max = 0w59 | ||
111 : | | hash Min = 0w61 | ||
112 : | | hash Sin = 0w67 | ||
113 : | | hash Cos = 0w71 | ||
114 : | | hash Pow = 0w73 | ||
115 : | | hash IntToReal = 0w79 | ||
116 : | | hash TruncToInt = 0w83 | ||
117 : | | hash RoundToInt = 0w89 | ||
118 : | | hash CeilToInt = 0w97 | ||
119 : | | hash FloorToInt = 0w101 | ||
120 : | | hash (LoadImage img) = 0w103 + ImageInfo.hash img | ||
121 : | | hash Inside = 0w107 | ||
122 : | | hash (Field fld) = 0w109 + FieldDef.hash fld | ||
123 : | | hash Probe = 0w113 | ||
124 : | | hash (Transform img) = 0w127 + ImageInfo.hash img | ||
125 : | |||
126 : | val toString : rator -> string | ||
127 : | |||
128 : | end | ||
129 : | |||
130 : | structure HighIL = SSAFn(HighOps) |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |