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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 548 - (view) (download)

1 : jhr 391 (* mid-il-types.sml
2 :     *
3 : jhr 435 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 : jhr 391 * All rights reserved.
5 :     *
6 :     * Types for the MidIL.
7 :     *)
8 :    
9 :     structure MidILTypes =
10 :     struct
11 :    
12 :     datatype ty
13 :     = BoolTy | StringTy
14 :     | IVecTy of int (* integers; both scalars and vectors *)
15 :     | VecTy of int (* reals; both scalars and vectors *)
16 : jhr 548 | AddrTy of ImageInfo.info (* voxel address *)
17 :     | ImageTy of ImageInfo.info
18 : jhr 391
19 : jhr 427 val intTy = IVecTy 1
20 :     val realTy = VecTy 1
21 : jhr 391
22 : jhr 548 fun same (BoolTy, BoolTy) = true
23 :     | same (StringTy, StringTy) = true
24 :     | same (IVecTy n1, IVecTy n2) = (n1 = n2)
25 :     | same (VecTy n1, VecTy n2) = (n1 = n2)
26 :     | same (AddrTy info1, AddrTy info2) = ImageInfo.same(info1, info2)
27 :     | same (ImageTy info1, ImageTy info2) = ImageInfo.same(info1, info2)
28 :     | same _ = false
29 : jhr 391
30 :     fun hash BoolTy = 0w1
31 :     | hash StringTy = 0w2
32 :     | hash (IVecTy d) = 0w7 * Word.fromInt d + 0w3
33 :     | hash (VecTy d) = 0w11 * Word.fromInt d + 0w4
34 : jhr 548 | hash (AddrTy info) = 0w5 + ImageInfo.hash info
35 :     | hash (ImageTy info) = 0w13 * ImageInfo.hash info + 0w6
36 : jhr 391
37 :     fun toString BoolTy = "bool"
38 :     | toString StringTy = "string"
39 : jhr 427 | toString (IVecTy 1) = "int"
40 : jhr 391 | toString (IVecTy d) = "int" ^ Int.toString d
41 : jhr 427 | toString (VecTy 1) = "real"
42 : jhr 391 | toString (VecTy d) = "real" ^ Int.toString d
43 : jhr 548 | toString (AddrTy info) = concat["addr(", ImageInfo.toString info, ")"]
44 :     | toString (ImageTy info) = concat["image(", ImageInfo.toString info, ")"]
45 : jhr 391
46 :     end

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