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

SCM Repository

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

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

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

revision 735, Sat Apr 2 17:27:39 2011 UTC revision 736, Sat Apr 2 18:50:43 2011 UTC
# Line 11  Line 11 
11    
12      datatype ty      datatype ty
13        = BoolTy | StringTy        = BoolTy | StringTy
14        | IVecTy of int           (* integers; both scalars and vectors *)        | IVecTy of int           (* integers; both scalars and sequences *)
15        | VecTy of int            (* reals; both scalars and vectors *)        | TensorTy of int list    (* tensor types, which include reals, sequences of reals, etc. *)
16        | AddrTy of ImageInfo.info (* voxel address *)        | AddrTy of ImageInfo.info (* voxel address *)
17        | ImageTy of ImageInfo.info        | ImageTy of ImageInfo.info
18    
19      val intTy = IVecTy 1      val intTy = IVecTy 1
20      val realTy = VecTy 1      val realTy = TensorTy[]
21        fun vecTy 1 = realTy
22          | vecTy n = TensorTy[n]
23    
24        fun tensorTy dd = (case (List.mapPartial (fn 1 => NONE | d => SOME d) dd)
25               of [] => realTy (* 0-order tensors are represented as reals *)
26                | dd => TensorTy dd
27              (* end case *))
28    
29      fun same (BoolTy, BoolTy) = true      fun same (BoolTy, BoolTy) = true
30        | same (StringTy, StringTy) = true        | same (StringTy, StringTy) = true
31        | same (IVecTy n1, IVecTy n2) = (n1 = n2)        | same (IVecTy n1, IVecTy n2) = (n1 = n2)
32        | same (VecTy n1, VecTy n2) = (n1 = n2)        | same (TensorTy dd1, TensorTy dd2) = (dd1 = dd2)
33        | same (AddrTy info1, AddrTy info2) = ImageInfo.same(info1, info2)        | same (AddrTy info1, AddrTy info2) = ImageInfo.same(info1, info2)
34        | same (ImageTy info1, ImageTy info2) = ImageInfo.same(info1, info2)        | same (ImageTy info1, ImageTy info2) = ImageInfo.same(info1, info2)
35        | same _ = false        | same _ = false
# Line 30  Line 37 
37      fun hash BoolTy = 0w1      fun hash BoolTy = 0w1
38        | hash StringTy = 0w2        | hash StringTy = 0w2
39        | hash (IVecTy d) = 0w7 * Word.fromInt d + 0w3        | hash (IVecTy d) = 0w7 * Word.fromInt d + 0w3
40        | hash (VecTy d) = 0w11 * Word.fromInt d + 0w4        | hash (TensorTy dd) = List.foldl (fn (d, s) => 0w11 * Word.fromInt d + s) 0w4 dd
41        | hash (AddrTy info) = 0w5 + ImageInfo.hash info        | hash (AddrTy info) = 0w5 + ImageInfo.hash info
42        | hash (ImageTy info) = 0w13 * ImageInfo.hash info + 0w6        | hash (ImageTy info) = 0w13 * ImageInfo.hash info + 0w6
43    
# Line 38  Line 45 
45        | toString StringTy = "string"        | toString StringTy = "string"
46        | toString (IVecTy 1) = "int"        | toString (IVecTy 1) = "int"
47        | toString (IVecTy d) = "int" ^ Int.toString d        | toString (IVecTy d) = "int" ^ Int.toString d
48        | toString (VecTy 1) = "real"        | toString (TensorTy[]) = "real"
49        | toString (VecTy d) = "real" ^ Int.toString d        | toString (TensorTy[d]) = "real" ^ Int.toString d
50          | toString (TensorTy dd) = String.concat[
51                "tensor[", String.concatWith "," (List.map Int.toString dd), "]"
52              ]
53        | toString (AddrTy info) = concat["addr(", ImageInfo.toString info, ")"]        | toString (AddrTy info) = concat["addr(", ImageInfo.toString info, ")"]
54        | toString (ImageTy info) = concat["image(", ImageInfo.toString info, ")"]        | toString (ImageTy info) = concat["image(", ImageInfo.toString info, ")"]
55    

Legend:
Removed from v.735  
changed lines
  Added in v.736

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