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

SCM Repository

[diderot] Diff of /trunk/src/compiler/IL/gen/high-il.sml
ViewVC logotype

Diff of /trunk/src/compiler/IL/gen/high-il.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 186, Thu Jul 29 04:26:57 2010 UTC revision 226, Tue Aug 3 21:34:18 2010 UTC
# Line 11  Line 11 
11  structure HighOps =  structure HighOps =
12    struct    struct
13    
14      type ty = BoolTy | StringTy | IntTy | TensorTy of int list      datatype ty = BoolTy | StringTy | IntTy | TensorTy of int list
15    
16      fun sameTy (ty1 : ty, ty2) = (ty1 = ty2)      fun samety (ty1 : ty, ty2) = (ty1 = ty2)
17        fun hashty BoolTy = 0w1
18          | hashty StringTy = 0w2
19          | hashty IntTy = 0w3
20          | hashty (TensorTy dd) = List.foldl (fn (d, s) => Word.fromInt d + s) 0w4 dd
21        fun tyToString BoolTy = "bool"
22          | tyToString StringTy = "string"
23          | tyToString IntTy = "int"
24          | tyToString (TensorTy dd) = String.concat[
25                "tensor[", String.concatWith "," (List.map Int.toString dd), "]"
26              ]
27    
28        fun samestring (s1 : string, s2) = (s1 = s2)
29        val hashstring = HashString.hashString
30        fun stringToString s = String.concat["\"", s, "\""]
31    
32      datatype rator      datatype rator
33        = Add of ty        = Add of ty
# Line 46  Line 60 
60        | RoundToInt        | RoundToInt
61        | CeilToInt        | CeilToInt
62        | FloorToInt        | FloorToInt
63          | Kernel of Kernel.kernel
64        | LoadImage of ImageInfo.info        | LoadImage of ImageInfo.info
65          | Convolve
66        | Inside        | Inside
67        | Field of FieldDef.field_def        | Field of FieldDef.field_def
68          | AddField
69          | ScaleField
70          | NegField
71          | DiffField
72        | Probe        | Probe
73        | Transform of ImageInfo.info        | Transform of ImageInfo.info
74          | Input of string
75          | InputWithDefault of string
76    
77      fun arity (Add _) = 2      fun arity (Add _) = 2
78        | arity (Sub _) = 2        | arity (Sub _) = 2
# Line 82  Line 104 
104        | arity RoundToInt = 1        | arity RoundToInt = 1
105        | arity CeilToInt = 1        | arity CeilToInt = 1
106        | arity FloorToInt = 1        | arity FloorToInt = 1
107        | arity (LoadImage _) = 1        | arity (Kernel _) = 0
108          | arity (LoadImage _) = 0
109          | arity Convolve = 2
110        | arity Inside = 2        | arity Inside = 2
111        | arity (Field _) = 0        | arity (Field _) = 0
112          | arity AddField = 2
113          | arity ScaleField = 2
114          | arity NegField = 1
115          | arity DiffField = 1
116        | arity Probe = 2        | arity Probe = 2
117        | arity (Transform _) = 1        | arity (Transform _) = 1
118          | arity (Input _) = 0
119          | arity (InputWithDefault _) = 1
120    
121      fun same (Add a, Add b) = samety(a, b)      fun same (Add a, Add b) = samety(a, b)
122        | same (Sub a, Sub b) = samety(a, b)        | same (Sub a, Sub b) = samety(a, b)
# Line 118  Line 148 
148        | same (RoundToInt, RoundToInt) = true        | same (RoundToInt, RoundToInt) = true
149        | same (CeilToInt, CeilToInt) = true        | same (CeilToInt, CeilToInt) = true
150        | same (FloorToInt, FloorToInt) = true        | same (FloorToInt, FloorToInt) = true
151          | same (Kernel a, Kernel b) = Kernel.same(a, b)
152        | same (LoadImage a, LoadImage b) = ImageInfo.same(a, b)        | same (LoadImage a, LoadImage b) = ImageInfo.same(a, b)
153          | same (Convolve, Convolve) = true
154        | same (Inside, Inside) = true        | same (Inside, Inside) = true
155        | same (Field a, Field b) = FieldDef.same(a, b)        | same (Field a, Field b) = FieldDef.same(a, b)
156          | same (AddField, AddField) = true
157          | same (ScaleField, ScaleField) = true
158          | same (NegField, NegField) = true
159          | same (DiffField, DiffField) = true
160        | same (Probe, Probe) = true        | same (Probe, Probe) = true
161        | same (Transform a, Transform b) = ImageInfo.same(a, b)        | same (Transform a, Transform b) = ImageInfo.same(a, b)
162          | same (Input a, Input b) = samestring(a, b)
163          | same (InputWithDefault a, InputWithDefault b) = samestring(a, b)
164        | same _ = false        | same _ = false
165    
166      fun hash (Add a) = 0w3 + hashty a      fun hash (Add a) = 0w3 + hashty a
# Line 155  Line 193 
193        | hash RoundToInt = 0w109        | hash RoundToInt = 0w109
194        | hash CeilToInt = 0w113        | hash CeilToInt = 0w113
195        | hash FloorToInt = 0w127        | hash FloorToInt = 0w127
196        | hash (LoadImage a) = 0w131 + ImageInfo.hash a        | hash (Kernel a) = 0w131 + Kernel.hash a
197        | hash Inside = 0w137        | hash (LoadImage a) = 0w137 + ImageInfo.hash a
198        | hash (Field a) = 0w139 + FieldDef.hash a        | hash Convolve = 0w139
199        | hash Probe = 0w149        | hash Inside = 0w149
200        | hash (Transform a) = 0w151 + ImageInfo.hash a        | hash (Field a) = 0w151 + FieldDef.hash a
201          | hash AddField = 0w157
202          | hash ScaleField = 0w163
203          | hash NegField = 0w167
204          | hash DiffField = 0w173
205          | hash Probe = 0w179
206          | hash (Transform a) = 0w181 + ImageInfo.hash a
207          | hash (Input a) = 0w191 + hashstring a
208          | hash (InputWithDefault a) = 0w193 + hashstring a
209    
210      fun toString (Add a) = concat["Add(", tyToString a, ")"]      fun toString (Add a) = concat["Add(", tyToString a, ")"]
211        | toString (Sub a) = concat["Sub(", tyToString a, ")"]        | toString (Sub a) = concat["Sub(", tyToString a, ")"]
# Line 191  Line 237 
237        | toString RoundToInt = "RoundToInt"        | toString RoundToInt = "RoundToInt"
238        | toString CeilToInt = "CeilToInt"        | toString CeilToInt = "CeilToInt"
239        | toString FloorToInt = "FloorToInt"        | toString FloorToInt = "FloorToInt"
240          | toString (Kernel a) = concat["Kernel(", Kernel.toString a, ")"]
241        | toString (LoadImage a) = concat["LoadImage(", ImageInfo.toString a, ")"]        | toString (LoadImage a) = concat["LoadImage(", ImageInfo.toString a, ")"]
242          | toString Convolve = "Convolve"
243        | toString Inside = "Inside"        | toString Inside = "Inside"
244        | toString (Field a) = concat["Field(", FieldDef.toString a, ")"]        | toString (Field a) = concat["Field(", FieldDef.toString a, ")"]
245          | toString AddField = "AddField"
246          | toString ScaleField = "ScaleField"
247          | toString NegField = "NegField"
248          | toString DiffField = "DiffField"
249        | toString Probe = "Probe"        | toString Probe = "Probe"
250        | toString (Transform a) = concat["Transform(", ImageInfo.toString a, ")"]        | toString (Transform a) = concat["Transform(", ImageInfo.toString a, ")"]
251          | toString (Input a) = concat["Input(", stringToString a, ")"]
252          | toString (InputWithDefault a) = concat["InputWithDefault(", stringToString a, ")"]
253    
254    end    end
255    
256  structure HighIL = SSAFn(HighOps)  structure HighIL = SSAFn(HighOps)
  hash (Add a) = 0w587 + hash ty  a  
       | hash (Add a) = 0w593 + hash ty  a  
       | hash (Add a) = 0w599 + hash ty  a  
       | hash (Add a) = 0w601 + hash ty  a  
       | hash (Add a) = 0w607 + hash ty  a  
       | hash (Add a) = 0w613 + hash ty  a  
       | hash (Add a) = 0w617 + hash ty  a  
       | hash (Add a) = 0w619 + hash ty  a  
       | hash (Add a) = 0w631 + hash ty  a  
       | hash (Add a) = 0w641 + hash ty  a  
       | hash (Add a) = 0w643 + hash ty  a  
       | hash (Add a) = 0w647 + hash ty  a  
       | hash (Add a) = 0w653 + hash ty  a  
       | hash (Add a) = 0w659 + hash ty  a  
       | hash (Add a) = 0w661 + hash ty  a  
       | hash (Add a) = 0w673 + hash ty  a  
       | hash (Add a) = 0w677 + hash ty  a  
       | hash (Add a) = 0w683 + hash ty  a  
       | hash (Add a) = 0w691 + hash ty  a  
       | hash (Add a) = 0w701 + hash ty  a  
       | hash (Add a) = 0w709 + hash ty  a  
       | hash (Add a) = 0w719 + hash ty  a  
       | hash (Add a) = 0w727 + hash ty  a  
       | hash (Add a) = 0w733 + hash ty  a  
       | hash (Add a) = 0w739 + hash ty  a  
       | hash (Add a) = 0w743 + hash ty  a  
       | hash (Add a) = 0w751 + hash ty  a  
       | hash (Add a) = 0w757 + hash ty  a  
       | hash (Add a) = 0w761 + hash ty  a  
       | hash (Add a) = 0w769 + hash ty  a  
       | hash (Add a) = 0w773 + hash ty  a  
       | hash (Add a) = 0w787 + hash ty  a  
       | hash (Add a) = 0w797 + hash ty  a  
       | hash (Add a) = 0w809 + hash ty  a  
       | hash (Add a) = 0w811 + hash ty  a  
       | hash (Add a) = 0w821 + hash ty  a  
       | hash (Add a) = 0w823 + hash ty  a  
       | hash (Add a) = 0w827 + hash ty  a  
       | hash (Add a) = 0w829 + hash ty  a  
       | hash (Add a) = 0w839 + hash ty  a  
       | hash (Add a) = 0w853 + hash ty  a  
       | hash (Add a) = 0w857 + hash ty  a  
       | hash (Add a) = 0w859 + hash ty  a  
       | hash (Add a) = 0w863 + hash ty  a  
       | hash (Add a) = 0w877 + hash ty  a  
       | hash (Add a) = 0w881 + hash ty  a  
       | hash (Add a) = 0w883 + hash ty  a  
       | hash (Add a) = 0w887 + hash ty  a  
       | hash (Add a) = 0w907 + hash ty  a  
       | hash (Add a) = 0w911 + hash ty  a  
       | hash (Add a) = 0w919 + hash ty  a  
       | hash (Add a) = 0w929 + hash ty  a  
       | hash (Add a) = 0w937 + hash ty  a  
       | hash (Add a) = 0w941 + hash ty  a  
       | hash (Add a) = 0w947 + hash ty  a  
       | hash (Add a) = 0w953 + hash ty  a  
       | hash (Add a) = 0w967 + hash ty  a  
       | hash (Add a) = 0w971 + hash ty  a  
       | hash (Add a) = 0w977 + hash ty  a  
       | hash (Add a) = 0w983 + hash ty  a  
       | hash (Add a) = 0w991 + hash ty  a  
       | hash (Add a) = 0w997 + hash ty  a  
       | hash (Add a) = 0w1009 + hash ty  a  
       | hash (Add a) = 0w1013 + hash ty  a  
       | hash (Add a) = 0w1019 + hash ty  a  
       | hash (Add a) = 0w1021 + hash ty  a  
       | hash (Add a) = 0w1031 + hash ty  a  
       | hash (Add a) = 0w1033 + hash ty  a  
       | hash (Add a) = 0w1039 + hash ty  a  
       | hash (Add a) = 0w1049 + hash ty  a  
       | hash (Add a) = 0w1051 + hash ty  a  
       | hash (Add a) = 0w1061 + hash ty  a  
       | hash (Add a) = 0w1063 + hash ty  a  
       | hash (Add a) = 0w1069 + hash ty  a  
       | hash (Add a) = 0w1087 + hash ty  a  
       | hash (Add a) = 0w1091 + hash ty  a  
       | hash (Add a) = 0w1093 + hash ty  a  
       | hash (Add a) = 0w1097 + hash ty  a  
       | hash (Add a) = 0w1103 + hash ty  a  
       | hash (Add a) = 0w1109 + hash ty  a  
       | hash (Add a) = 0w1117 + hash ty  a  
       | hash (Add a) = 0w1123 + hash ty  a  
       | hash (Add a) = 0w1129 + hash ty  a  
       | hash (Add a) = 0w1151 + hash ty  a  
       | hash (Add a) = 0w1153 + hash ty  a  
       | hash (Add a) = 0w1163 + hash ty  a  
       | hash (Add a) = 0w1171 + hash ty  a  
       | hash (Add a) = 0w1181 + hash ty  a  
       | hash (Add a) = 0w1187 + hash ty  a  
       | hash (Add a) = 0w1193 + hash ty  a  
       | hash (Add a) = 0w1201 + hash ty  a  
       | hash (Add a) = 0w1213 + hash ty  a  
       | hash (Add a) = 0w1217 + hash ty  a  
       | hash (Add a) = 0w1223 + hash ty  a  
       | hash  

Legend:
Removed from v.186  
changed lines
  Added in v.226

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