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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/tree-ir/tree-types.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/tree-ir/tree-types.sml

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

revision 3762, Fri Apr 15 21:09:15 2016 UTC revision 3766, Mon Apr 18 16:13:31 2016 UTC
# Line 13  Line 13 
13    
14      datatype ty      datatype ty
15        = BoolTy | StringTy | IntTy | RealTy        = BoolTy | StringTy | IntTy | RealTy
16  (* FIXME: we could use just CompVecTy[] for RealTy and CompVecTy[d] for VecTy(d). *)        | VecTy of int * bool * int list  (* vectors have a width and a representation that
17        | VecTy of int                    (* real vector of given width *)                                           * is spread across hardware-supported vectors.
18        | CompVecTy of int list           (* composite vector with the given pieces *)                                           * The boolean is true if the type is padded out.
19                                             *)
20    (* QUESTION: perhaps at this point, we should just represent higher-order tensors
21     * as SeqTy types?
22     *)
23        | TensorTy of int * ty            (* type of 2nd-order (or higher) tensor *)        | TensorTy of int * ty            (* type of 2nd-order (or higher) tensor *)
24        | TupleTy of ty list              (* tuples; used for multiple return values *)        | TupleTy of ty list              (* tuples; used for multiple return values *)
25        | SeqTy of ty * int option        | SeqTy of ty * int option
# Line 25  Line 29 
29      val intTy = IntTy      val intTy = IntTy
30      val realTy = RealTy      val realTy = RealTy
31      fun vecTy 1 = RealTy      fun vecTy 1 = RealTy
32        | vecTy n = VecTy n        | vecTy n = VecTy(n, [n])
33      fun iVecTy 1 = IntTy      fun iVecTy 1 = IntTy
34        | iVecTy n = SeqTy(IntTy, SOME n)        | iVecTy n = SeqTy(IntTy, SOME n)
35    
# Line 34  Line 38 
38        | tensorTy arg = TensorTy arg        | tensorTy arg = TensorTy arg
39    
40    (* is a type a composite-vector type? *)    (* is a type a composite-vector type? *)
41      fun isCompVecTy (CompVecTy _) = true      fun isCompVecTy (VecTy(_, _::_::_)) = true
42        | isCompVecTy _ = false        | isCompVecTy _ = false
43    
44      fun same (BoolTy, BoolTy) = true      fun same (BoolTy, BoolTy) = true
45        | same (StringTy, StringTy) = true        | same (StringTy, StringTy) = true
46        | same (IntTy, IntTy) = true        | same (IntTy, IntTy) = true
47        | same (RealTy, RealTy) = true        | same (RealTy, RealTy) = true
48        | same (VecTy d1, VecTy d2) = (d1 = d2)        | same (VecTy(d1, vs1), VecTy(d2, vs2)) = (d1 = d2) andalso ListPair.allEq (op =) (vs1, vs2)
       | same (CompVecTy dd1, CompVecTy dd2) = ListPair.allEq (op =) (dd1, dd2)  
49        | same (TensorTy(d1, ty1), TensorTy(d2, ty2)) = (d1 = d2) andalso same(ty1, ty2)        | same (TensorTy(d1, ty1), TensorTy(d2, ty2)) = (d1 = d2) andalso same(ty1, ty2)
50        | same (TupleTy tys1, TupleTy tys2) = ListPair.allEq same (tys1, tys2)        | same (TupleTy tys1, TupleTy tys2) = ListPair.allEq same (tys1, tys2)
51        | same (SeqTy(ty1, NONE), SeqTy(ty2, NONE)) = same(ty1, ty2)        | same (SeqTy(ty1, NONE), SeqTy(ty2, NONE)) = same(ty1, ty2)
# Line 55  Line 58 
58        | hash StringTy = 0w2        | hash StringTy = 0w2
59        | hash IntTy = 0w3        | hash IntTy = 0w3
60        | hash RealTy = 0w5        | hash RealTy = 0w5
61        | hash (VecTy d) = 0w7 * Word.fromInt d        | hash (VecTy(d, vs)) =
62        | hash (CompVecTy dd) = List.foldl (fn (d, s) => 0w11 * Word.fromInt d + s) 0w5 dd            List.foldl (fn (d, s) => 0w11 * Word.fromInt d + s) (0w7 * Word.fromInt d) vs
63        | hash (TensorTy(d, ty)) = 0w13 * (Word.fromInt d + hash ty)        | hash (TensorTy(d, ty)) = 0w13 * (Word.fromInt d + hash ty)
64        | hash (TupleTy tys) = List.foldl (fn (ty, s) => hash ty + s) 0w17 tys        | hash (TupleTy tys) = List.foldl (fn (ty, s) => hash ty + s) 0w17 tys
65        | hash (SeqTy(ty, NONE)) = hash ty + 0w19        | hash (SeqTy(ty, NONE)) = hash ty + 0w19
# Line 68  Line 71 
71        | toString StringTy = "string"        | toString StringTy = "string"
72        | toString IntTy = "int"        | toString IntTy = "int"
73        | toString RealTy = "real"        | toString RealTy = "real"
74        | toString (VecTy d) = "vec" ^ Int.toString d        | toString (VecTy(d, [_])) = "vec" ^ Int.toString d
75        | toString (CompVecTy dd) = String.concat [        | toString (CompVecTy(d, vs)) = String.concat [
76              "vecs{", String.concatWithMap ":" Int.toString dd, "}"              "vec", Int.toStirng d, "{", String.concatWithMap ":" Int.toString vs, "}"
77            ]            ]
78        | toString (TensorTy(d, ty)) = String.concat [        | toString (TensorTy(d, ty)) = String.concat [
79              "tensor(", Int.toString d, ",", toString ty, ")"              "tensor(", Int.toString d, ",", toString ty, ")"

Legend:
Removed from v.3762  
changed lines
  Added in v.3766

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