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

SCM Repository

[diderot] Annotation of /trunk/src/compiler/high-il/high-il-types.sml
ViewVC logotype

Annotation of /trunk/src/compiler/high-il/high-il-types.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 426 - (view) (download)

1 : jhr 393 (* high-il-types.sml
2 :     *
3 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *)
6 :    
7 :     structure HighILTypes =
8 :     struct
9 :    
10 : jhr 394 datatype ty
11 :     = BoolTy | StringTy | IntTy
12 :     | TensorTy of int list
13 :     | KernelTy | ImageTy | FieldTy
14 : jhr 393
15 : jhr 417 val intTy = IntTy
16 : jhr 403 val realTy = TensorTy[]
17 :     val vec3Ty = TensorTy[3]
18 :    
19 : jhr 426 (* smart constructor for tensor type that prunes out dimensions with size 1 *)
20 :     fun tensorTy dd = TensorTy(List.mapPartial (fn 1 => NONE | d => SOME d) dd)
21 :    
22 : jhr 393 fun same (ty1 : ty, ty2) = (ty1 = ty2)
23 :    
24 :     fun hash BoolTy = 0w1
25 :     | hash StringTy = 0w2
26 :     | hash IntTy = 0w3
27 :     | hash (TensorTy dd) = List.foldl (fn (d, s) => Word.fromInt d + s) 0w4 dd
28 : jhr 395 | hash KernelTy = 0w5
29 :     | hash ImageTy = 0w6
30 :     | hash FieldTy = 0w7
31 : jhr 393
32 :     fun toString BoolTy = "bool"
33 :     | toString StringTy = "string"
34 :     | toString IntTy = "int"
35 :     | toString (TensorTy[]) = "real"
36 :     | toString (TensorTy dd) = String.concat[
37 :     "tensor[", String.concatWith "," (List.map Int.toString dd), "]"
38 :     ]
39 : jhr 395 | toString KernelTy = "kernel"
40 :     | toString ImageTy = "image"
41 :     | toString FieldTy = "field"
42 : jhr 393
43 :     end

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