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 3766, Mon Apr 18 16:13:31 2016 UTC revision 3767, Mon Apr 18 18:42:10 2016 UTC
# Line 29  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, [n])        | vecTy n = VecTy(n, false, [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 38  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 (VecTy(_, _::_::_)) = 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, vs1), VecTy(d2, vs2)) = (d1 = d2) andalso ListPair.allEq (op =) (vs1, vs2)        | same (VecTy(d1, b1, vs1), VecTy(d2, b2, vs2)) =
49              (d1 = d2) andalso (b1 = b2) andalso ListPair.allEq (op =) (vs1, vs2)
50        | 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)
51        | same (TupleTy tys1, TupleTy tys2) = ListPair.allEq same (tys1, tys2)        | same (TupleTy tys1, TupleTy tys2) = ListPair.allEq same (tys1, tys2)
52        | same (SeqTy(ty1, NONE), SeqTy(ty2, NONE)) = same(ty1, ty2)        | same (SeqTy(ty1, NONE), SeqTy(ty2, NONE)) = same(ty1, ty2)
# Line 58  Line 59 
59        | hash StringTy = 0w2        | hash StringTy = 0w2
60        | hash IntTy = 0w3        | hash IntTy = 0w3
61        | hash RealTy = 0w5        | hash RealTy = 0w5
62        | hash (VecTy(d, vs)) =        | hash (VecTy(d, _, vs)) =
63            List.foldl (fn (d, s) => 0w11 * Word.fromInt d + s) (0w7 * Word.fromInt d) vs            List.foldl (fn (d, s) => 0w11 * Word.fromInt d + s) (0w7 * Word.fromInt d) vs
64        | hash (TensorTy(d, ty)) = 0w13 * (Word.fromInt d + hash ty)        | hash (TensorTy(d, ty)) = 0w13 * (Word.fromInt d + hash ty)
65        | 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
# Line 71  Line 72 
72        | toString StringTy = "string"        | toString StringTy = "string"
73        | toString IntTy = "int"        | toString IntTy = "int"
74        | toString RealTy = "real"        | toString RealTy = "real"
75        | toString (VecTy(d, [_])) = "vec" ^ Int.toString d        | toString (VecTy(d, _, [_])) = "vec" ^ Int.toString d
76        | toString (CompVecTy(d, vs)) = String.concat [        | toString (VecTy(d, _, vs)) = String.concat [
77              "vec", Int.toStirng d, "{", String.concatWithMap ":" Int.toString vs, "}"              "vec", Int.toString d, "{", String.concatWithMap ":" Int.toString vs, "}"
78            ]            ]
79        | toString (TensorTy(d, ty)) = String.concat [        | toString (TensorTy(d, ty)) = String.concat [
80              "tensor(", Int.toString d, ",", toString ty, ")"              "tensor(", Int.toString d, ",", toString ty, ")"

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

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