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 3995 - (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 : jhr 3861 type target_info = {
19 :     layout : int -> TreeTypes.vec_layout,
20 :     isInline : LowOps.rator -> bool
21 :     }
22 :    
23 : jhr 3691 datatype program = Program of {
24 :     props : Properties.t list,
25 : jhr 3861 target : target_info, (* target-specific info about representation invariants *)
26 : jhr 3691 consts : global_var list, (* large constant variables *)
27 :     inputs : input list, (* global input variables *)
28 :     constInit : block, (* code that initializes constants and inputs *)
29 :     globals : global_var list, (* other global variables *)
30 : jhr 3995 globInit : block, (* CFG to initialize other globals (if any) *)
31 : jhr 3691 strand : strand, (* the strand definition *)
32 :     create : create, (* initial strand creation *)
33 : jhr 3995 init : block option, (* optional global initially code *)
34 :     update : block option (* optional global update code. *)
35 : jhr 3691 }
36 :    
37 :     and strand = Strand of {
38 :     name : Atom.atom,
39 :     params : var list,
40 :     state : state_var list,
41 : jhr 3952 stateInit : method,
42 :     initM : method option,
43 :     updateM : method,
44 :     stabilizeM : method option
45 : jhr 3691 }
46 :    
47 : jhr 3952 and method = Method of {
48 :     usesGlobals : bool, (* does the method contain references to globals? *)
49 :     needsWorld : bool, (* does the method need the world (e.g., to print) *)
50 :     body : block (* the method body *)
51 :     }
52 :    
53 : jhr 3691 and create = Create of {
54 :     dim : int option, (* grid dimension; NONE for collections *)
55 :     code : block (* the loop nest for creating the strands *)
56 :     }
57 :    
58 :     and block = Block of {
59 : jhr 3848 locals : var list ref, (* the local variables that are used in this block *)
60 : jhr 3691 body : stm list
61 :     }
62 :    
63 :     and stm
64 :     = S_Comment of string list
65 : jhr 3892 | S_Assign of bool * var * exp (* assignment; the boolean is true for var decls *)
66 : jhr 3844 | S_MAssign of var list * exp
67 : jhr 3691 | S_GAssign of global_var * exp
68 :     | S_IfThen of exp * block
69 :     | S_IfThenElse of exp * block * block
70 : jhr 3924 | S_For of var * exp * exp * block
71 : jhr 3691 | S_Foreach of var * exp * block
72 :     (* special Diderot forms *)
73 : jhr 3894 | S_LoadNrrd of var * APITypes.t * string
74 : jhr 3691 | S_Input of global_var * string * string option * exp option (* get input *)
75 :     | S_InputNrrd of global_var * string * string option * string option (* get image/seq input *)
76 :     | S_New of Atom.atom * exp list (* new strand creation *)
77 : jhr 3767 | S_Save of state_var * exp (* save strand state *)
78 : jhr 3959 (* QUESTION: do we need S_Exit? *)
79 : jhr 3835 | S_Exit
80 : jhr 3810 | S_Print of Ty.t list * exp list
81 : jhr 3691 (* return functions for methods *)
82 :     | S_Active
83 :     | S_Stabilize
84 :     | S_Die
85 :    
86 :     and exp
87 :     = E_Global of global_var
88 : jhr 3852 | E_State of exp option * state_var
89 : jhr 3691 | E_Var of var
90 :     | E_Lit of Literal.t
91 :     | E_Op of Op.rator * exp list
92 : jhr 3889 | E_Vec of int * int * exp list (* vector value; the ints are the width and the
93 :     * padded width
94 :     *)
95 : jhr 3852 | E_Cons of exp list * Ty.t (* in-memory tensor value *)
96 : jhr 3810 | E_Seq of exp list * Ty.t
97 : jhr 3850 | E_Pack of Ty.vec_layout * exp list (* pack vector pieces into composite vector value *)
98 : jhr 3862 | E_VLoad of Ty.vec_layout * exp * int (* load a piece of a composite vector value from
99 : jhr 3883 * a tensor. The integer specifies the index of
100 :     * the piece.
101 : jhr 3862 *)
102 : jhr 3691
103 :     and global_var = GV of {
104 : jhr 3813 name : string, (* name (should be unique) *)
105 :     ty : Ty.t, (* type *)
106 :     xty : APITypes.t option, (* external type (for inputs and outputs) *)
107 : jhr 3832 input : bool, (* is an input variable *)
108 :     output : bool, (* is the output value of the strand *)
109 :     varying : bool (* varies over the execution of the program *)
110 : jhr 3691 }
111 :    
112 :     and state_var = SV of {
113 : jhr 3813 name : string, (* name (should be unique) *)
114 :     ty : Ty.t, (* type *)
115 : jhr 3832 xty : APITypes.t option, (* external type (for outputs) *)
116 :     varying : bool (* varies over the lifetime of the strand *)
117 : jhr 3691 }
118 :    
119 :     and var = V of {
120 :     name : string, (* name (should be unique) *)
121 :     id : Stamp.stamp, (* unique ID *)
122 : jhr 3813 ty : Ty.t (* type *)
123 : jhr 3691 }
124 :    
125 :     withtype input = global_var Inputs.input
126 :    
127 :     end

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