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

SCM Repository

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

Annotation of /branches/vis15/src/compiler/tree-ir/tree-ir.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3857 - (view) (download)

1 : jhr 3691 (* tree-ir.sml
2 :     *
3 :     * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     *
5 :     * COPYRIGHT (c) 2016 The University of Chicago
6 :     * All rights reserved.
7 :     *
8 :     * This representation restores the block structure and nested expression syntax
9 :     * of the source language.
10 :     *)
11 :    
12 :     structure TreeIR =
13 :     struct
14 :    
15 : jhr 3757 structure Op = TreeOps
16 : jhr 3750 structure Ty = TreeTypes
17 : jhr 3691
18 :     datatype program = Program of {
19 :     props : Properties.t list,
20 :     consts : global_var list, (* large constant variables *)
21 :     inputs : input list, (* global input variables *)
22 :     constInit : block, (* code that initializes constants and inputs *)
23 :     globals : global_var list, (* other global variables *)
24 :     globalInit : block, (* CFG to initialize other globals (if any) *)
25 :     strand : strand, (* the strand definition *)
26 :     create : create, (* initial strand creation *)
27 :     update : block option (* optional update code. *)
28 :     }
29 :    
30 :     and strand = Strand of {
31 :     name : Atom.atom,
32 :     params : var list,
33 :     state : state_var list,
34 :     stateInit : block,
35 :     initM : block option,
36 :     updateM : block,
37 :     stabilizeM : block option
38 :     }
39 :    
40 :     and create = Create of {
41 :     dim : int option, (* grid dimension; NONE for collections *)
42 :     code : block (* the loop nest for creating the strands *)
43 :     }
44 :    
45 :     and block = Block of {
46 : jhr 3848 locals : var list ref, (* the local variables that are used in this block *)
47 : jhr 3691 body : stm list
48 :     }
49 :    
50 :     and stm
51 :     = S_Comment of string list
52 : jhr 3857 | S_Assign of bool * var * exp
53 : jhr 3844 | S_MAssign of var list * exp
54 : jhr 3691 | S_GAssign of global_var * exp
55 :     | S_IfThen of exp * block
56 :     | S_IfThenElse of exp * block * block
57 :     | S_Foreach of var * exp * block
58 :     (* special Diderot forms *)
59 : jhr 3754 | S_LoadNrrd of var * string
60 : jhr 3691 | S_Input of global_var * string * string option * exp option (* get input *)
61 :     | S_InputNrrd of global_var * string * string option * string option (* get image/seq input *)
62 :     | S_New of Atom.atom * exp list (* new strand creation *)
63 : jhr 3767 | S_Save of state_var * exp (* save strand state *)
64 : jhr 3835 | S_Exit
65 : jhr 3810 | S_Print of Ty.t list * exp list
66 : jhr 3691 (* return functions for methods *)
67 :     | S_Active
68 :     | S_Stabilize
69 :     | S_Die
70 :    
71 :     and exp
72 :     = E_Global of global_var
73 : jhr 3852 | E_State of exp option * state_var
74 : jhr 3691 | E_Var of var
75 :     | E_Lit of Literal.t
76 :     | E_Op of Op.rator * exp list
77 : jhr 3852 | E_Vec of exp list (* vector value *)
78 :     | E_Cons of exp list * Ty.t (* in-memory tensor value *)
79 : jhr 3810 | E_Seq of exp list * Ty.t
80 : jhr 3850 | E_Pack of Ty.vec_layout * exp list (* pack vector pieces into composite vector value *)
81 :     | E_VLoad of Ty.vec_layout * exp * int (* load a piece of a composite vector value *)
82 : jhr 3691
83 :     and global_var = GV of {
84 : jhr 3813 name : string, (* name (should be unique) *)
85 :     ty : Ty.t, (* type *)
86 :     xty : APITypes.t option, (* external type (for inputs and outputs) *)
87 : jhr 3832 input : bool, (* is an input variable *)
88 :     output : bool, (* is the output value of the strand *)
89 :     varying : bool (* varies over the execution of the program *)
90 : jhr 3691 }
91 :    
92 :     and state_var = SV of {
93 : jhr 3813 name : string, (* name (should be unique) *)
94 :     ty : Ty.t, (* type *)
95 : jhr 3832 xty : APITypes.t option, (* external type (for outputs) *)
96 :     varying : bool (* varies over the lifetime of the strand *)
97 : jhr 3691 }
98 :    
99 :     and var = V of {
100 :     name : string, (* name (should be unique) *)
101 :     id : Stamp.stamp, (* unique ID *)
102 : jhr 3813 ty : Ty.t (* type *)
103 : jhr 3691 }
104 :    
105 :     withtype input = global_var Inputs.input
106 :    
107 :     end

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