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

SCM Repository

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

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

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

revision 1639, Wed Nov 16 01:48:07 2011 UTC revision 1640, Wed Nov 16 02:19:51 2011 UTC
# Line 9  Line 9 
9  structure MidILTypes =  structure MidILTypes =
10    struct    struct
11    
12    (* FIXME: perhaps we should replage TensorTy wity SeqTy at this stage? *)
13      datatype ty      datatype ty
14        = BoolTy | StringTy        = BoolTy | StringTy | IntTy
       | IVecTy of int           (* integers; both scalars and sequences *)  
15        | TensorTy of int list    (* tensor types, which include reals, sequences of reals, etc. *)        | TensorTy of int list    (* tensor types, which include reals, sequences of reals, etc. *)
16          | TupleTy of ty list              (* tuples; used for multiple return values *)
17          | SeqTy of ty * int
18        | AddrTy of ImageInfo.info (* voxel address *)        | AddrTy of ImageInfo.info (* voxel address *)
19        | ImageTy of ImageInfo.info        | ImageTy of ImageInfo.info
20    
21      val intTy = IVecTy 1      val intTy = IntTy
22        fun iVecTy 1 = IntTy
23          | iVecTy n = SeqTy(IntTy, n)
24      val realTy = TensorTy[]      val realTy = TensorTy[]
25      fun vecTy 1 = realTy      fun vecTy 1 = realTy
26        | vecTy n = TensorTy[n]        | vecTy n = TensorTy[n]
# Line 28  Line 32 
32    
33      fun same (BoolTy, BoolTy) = true      fun same (BoolTy, BoolTy) = true
34        | same (StringTy, StringTy) = true        | same (StringTy, StringTy) = true
35        | same (IVecTy n1, IVecTy n2) = (n1 = n2)        | same (IntTy, IntTy) = true
36        | same (TensorTy dd1, TensorTy dd2) = (dd1 = dd2)        | same (TensorTy dd1, TensorTy dd2) = (dd1 = dd2)
37          | same (TupleTy tys1, TupleTy tys2) = ListPair.allEq same (tys1, tys2)
38          | same (SeqTy(ty1, n1), SeqTy(ty2, n2)) = (n1 = n2) andalso same(ty1, ty2)
39        | same (AddrTy info1, AddrTy info2) = ImageInfo.same(info1, info2)        | same (AddrTy info1, AddrTy info2) = ImageInfo.same(info1, info2)
40        | same (ImageTy info1, ImageTy info2) = ImageInfo.same(info1, info2)        | same (ImageTy info1, ImageTy info2) = ImageInfo.same(info1, info2)
41        | same _ = false        | same _ = false
42    
43      fun hash BoolTy = 0w1      fun hash BoolTy = 0w1
44        | hash StringTy = 0w2        | hash StringTy = 0w2
45        | hash (IVecTy d) = 0w7 * Word.fromInt d + 0w3        | hash IntTy = 0w3
46        | hash (TensorTy dd) = List.foldl (fn (d, s) => 0w11 * Word.fromInt d + s) 0w4 dd        | hash (TensorTy dd) = List.foldl (fn (d, s) => 0w11 * Word.fromInt d + s) 0w4 dd
47          | hash (TupleTy tys) = List.foldl (fn (ty, s) => hash ty + s) 0w7 tys
48          | hash (SeqTy(ty, n)) = Word.fromInt n * hash ty + 0w11
49        | hash (AddrTy info) = 0w5 + ImageInfo.hash info        | hash (AddrTy info) = 0w5 + ImageInfo.hash info
50        | hash (ImageTy info) = 0w13 * ImageInfo.hash info + 0w6        | hash (ImageTy info) = 0w13 * ImageInfo.hash info + 0w6
51    
52      fun toString BoolTy = "bool"      fun toString BoolTy = "bool"
53        | toString StringTy = "string"        | toString StringTy = "string"
54        | toString (IVecTy 1) = "int"        | toString IntTy = "int"
       | toString (IVecTy d) = "int" ^ Int.toString d  
55        | toString (TensorTy[]) = "real"        | toString (TensorTy[]) = "real"
56        | toString (TensorTy[d]) = "real" ^ Int.toString d        | toString (TensorTy[d]) = "real" ^ Int.toString d
57        | toString (TensorTy dd) = String.concat[        | toString (TensorTy dd) = String.concat[
58              "tensor[", String.concatWith "," (List.map Int.toString dd), "]"              "tensor[", String.concatWith "," (List.map Int.toString dd), "]"
59            ]            ]
60          | toString (TupleTy tys) = String.concat[
61                "(", String.concatWith " * " (List.map toString tys), ")"
62              ]
63          | toString (SeqTy(ty, n)) = concat[toString ty, "{", Int.toString n, "}"]
64        | toString (AddrTy info) = concat["addr(", ImageInfo.toString info, ")"]        | toString (AddrTy info) = concat["addr(", ImageInfo.toString info, ")"]
65        | toString (ImageTy info) = concat["image(", ImageInfo.toString info, ")"]        | toString (ImageTy info) = concat["image(", ImageInfo.toString info, ")"]
66    

Legend:
Removed from v.1639  
changed lines
  Added in v.1640

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