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 4045 - (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 block = Block of {
54 : jhr 3848 locals : var list ref, (* the local variables that are used in this block *)
55 : jhr 3691 body : stm list
56 :     }
57 :    
58 :     and stm
59 :     = S_Comment of string list
60 : jhr 3892 | S_Assign of bool * var * exp (* assignment; the boolean is true for var decls *)
61 : jhr 3844 | S_MAssign of var list * exp
62 : jhr 3691 | S_GAssign of global_var * exp
63 :     | S_IfThen of exp * block
64 :     | S_IfThenElse of exp * block * block
65 : jhr 3924 | S_For of var * exp * exp * block
66 : jhr 3691 | S_Foreach of var * exp * block
67 :     (* special Diderot forms *)
68 : jhr 3894 | S_LoadNrrd of var * APITypes.t * string
69 : jhr 3691 | S_Input of global_var * string * string option * exp option (* get input *)
70 :     | S_InputNrrd of global_var * string * string option * string option (* get image/seq input *)
71 :     | S_New of Atom.atom * exp list (* new strand creation *)
72 : jhr 3767 | S_Save of state_var * exp (* save strand state *)
73 : jhr 3959 (* QUESTION: do we need S_Exit? *)
74 : jhr 3835 | S_Exit
75 : jhr 3810 | S_Print of Ty.t list * exp list
76 : jhr 3691 (* return functions for methods *)
77 :     | S_Active
78 :     | S_Stabilize
79 :     | S_Die
80 :    
81 :     and exp
82 :     = E_Global of global_var
83 : jhr 3852 | E_State of exp option * state_var
84 : jhr 3691 | E_Var of var
85 :     | E_Lit of Literal.t
86 :     | E_Op of Op.rator * exp list
87 : jhr 3889 | E_Vec of int * int * exp list (* vector value; the ints are the width and the
88 :     * padded width
89 :     *)
90 : jhr 3852 | E_Cons of exp list * Ty.t (* in-memory tensor value *)
91 : jhr 3810 | E_Seq of exp list * Ty.t
92 : jhr 3850 | E_Pack of Ty.vec_layout * exp list (* pack vector pieces into composite vector value *)
93 : jhr 3862 | E_VLoad of Ty.vec_layout * exp * int (* load a piece of a composite vector value from
94 : jhr 3883 * a tensor. The integer specifies the index of
95 :     * the piece.
96 : jhr 3862 *)
97 : jhr 3691
98 :     and global_var = GV of {
99 : jhr 3813 name : string, (* name (should be unique) *)
100 :     ty : Ty.t, (* type *)
101 :     xty : APITypes.t option, (* external type (for inputs and outputs) *)
102 : jhr 3832 input : bool, (* is an input variable *)
103 :     output : bool, (* is the output value of the strand *)
104 :     varying : bool (* varies over the execution of the program *)
105 : jhr 3691 }
106 :    
107 :     and state_var = SV of {
108 : jhr 3813 name : string, (* name (should be unique) *)
109 :     ty : Ty.t, (* type *)
110 : jhr 3832 xty : APITypes.t option, (* external type (for outputs) *)
111 :     varying : bool (* varies over the lifetime of the strand *)
112 : jhr 3691 }
113 :    
114 :     and var = V of {
115 :     name : string, (* name (should be unique) *)
116 :     id : Stamp.stamp, (* unique ID *)
117 : jhr 3813 ty : Ty.t (* type *)
118 : jhr 3691 }
119 :    
120 :     withtype input = global_var Inputs.input
121 : jhr 4045 and create = block Create.t
122 : jhr 3691
123 :     end

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