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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/high-il/high-il-types.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/high-il/high-il-types.sml

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

trunk/src/compiler/high-il/high-il-types.sml revision 426, Mon Oct 18 18:49:55 2010 UTC branches/pure-cfg/src/compiler/high-il/high-il-types.sml revision 548, Thu Feb 17 22:41:53 2011 UTC
# Line 1  Line 1 
1  (* high-il-types.sml  (* high-il-types.sml
2   *   *
3   * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)   * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4   * All rights reserved.   * All rights reserved.
5   *)   *)
6    
# Line 10  Line 10 
10      datatype ty      datatype ty
11        = BoolTy | StringTy | IntTy        = BoolTy | StringTy | IntTy
12        | TensorTy of int list        | TensorTy of int list
13        | KernelTy | ImageTy | FieldTy        | ImageTy of int
14          | KernelTy
15          | FieldTy
16          | AnyTy           (* this is used in checking when we can't figure out the type *)
17    
18      val intTy = IntTy      val intTy = IntTy
19      val realTy = TensorTy[]      val realTy = TensorTy[]
# Line 19  Line 22 
22    (* smart constructor for tensor type that prunes out dimensions with size 1 *)    (* smart constructor for tensor type that prunes out dimensions with size 1 *)
23      fun tensorTy dd = TensorTy(List.mapPartial (fn 1 => NONE | d => SOME d) dd)      fun tensorTy dd = TensorTy(List.mapPartial (fn 1 => NONE | d => SOME d) dd)
24    
25      fun same (ty1 : ty, ty2) = (ty1 = ty2)      fun same (AnyTy, _) = true
26          | same (_, AnyTy) = true
27          | same (BoolTy, BoolTy) = true
28          | same (StringTy, StringTy) = true
29          | same (IntTy, IntTy) = true
30          | same (TensorTy dd1, TensorTy dd2) = (dd1 = dd2)
31          | same (ImageTy d1, ImageTy d2) = (d1 = d2)
32          | same (KernelTy, KernelTy) = true
33          | same (FieldTy, FieldTy) = true
34          | same _ = false
35    
36      fun hash BoolTy = 0w1      fun hash BoolTy = 0w1
37        | hash StringTy = 0w2        | hash StringTy = 0w2
38        | hash IntTy = 0w3        | hash IntTy = 0w3
39        | hash (TensorTy dd) = List.foldl (fn (d, s) => Word.fromInt d + s) 0w4 dd        | hash (TensorTy dd) = List.foldl (fn (d, s) => Word.fromInt d + s) 0w4 dd
40        | hash KernelTy = 0w5        | hash (ImageTy d) = 0w5 + 0w3 * Word.fromInt d
41        | hash ImageTy = 0w6        | hash KernelTy = 0w6
42        | hash FieldTy = 0w7        | hash FieldTy = 0w7
43          | hash AnyTy = raise Fail "hash(AnyTy)"
44    
45      fun toString BoolTy = "bool"      fun toString BoolTy = "bool"
46        | toString StringTy = "string"        | toString StringTy = "string"
# Line 36  Line 49 
49        | toString (TensorTy dd) = String.concat[        | toString (TensorTy dd) = String.concat[
50              "tensor[", String.concatWith "," (List.map Int.toString dd), "]"              "tensor[", String.concatWith "," (List.map Int.toString dd), "]"
51            ]            ]
52          | toString (ImageTy d) = String.concat["image", Int.toString d, "D"]
53        | toString KernelTy = "kernel"        | toString KernelTy = "kernel"
       | toString ImageTy = "image"  
54        | toString FieldTy = "field"        | toString FieldTy = "field"
55          | toString AnyTy = "**any**"
56    
57    end    end

Legend:
Removed from v.426  
changed lines
  Added in v.548

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