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

SCM Repository

[diderot] Diff of /branches/vis12/src/compiler/simplify/simple.sml
ViewVC logotype

Diff of /branches/vis12/src/compiler/simplify/simple.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/src/compiler/simplify/simple.sml revision 221, Tue Aug 3 20:13:55 2010 UTC branches/vis12/src/compiler/simplify/simple.sml revision 2141, Fri Feb 15 13:13:46 2013 UTC
# Line 1  Line 1 
1  (* simple.sml  (* simple.sml
2   *   *
3   * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)   * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4   * All rights reserved.   * All rights reserved.
5   *   *
6   * A simplified AST representation of a Diderot program   * A simplified AST representation of a Diderot program.  This representation has the property
7     * that the arguments to ifs, operators, etc. are variables and that the rhs of assignments
8     * consist of a single operation.  It is not, however, a single-assignment representation.
9   *)   *)
10    
11  structure Simple =  structure Simple =
# Line 14  Line 16 
16      datatype var = datatype AST.var      datatype var = datatype AST.var
17    
18      datatype program = Program of {      datatype program = Program of {
19            inputs : (var * Types.ty Inputs.input) list,
20          globals : var list,          globals : var list,
21          globalInit : block,          globalInit : block,
22          actors : actor list          funcs : func list,
23          (* initialization *)          strands : strand list,
24            init : init                     (* block evaluates any vars used in init *)
25        }        }
26    
27      and actor = Actor of {      and func = Func of {
28            f : var,
29            params : var list,
30            body : block
31          }
32    
33        and init = Initially of {
34            isArray : bool,
35            rangeInit : block,
36            iters : {param : var, lo : var, hi : var} list,
37            create : create
38          }
39    
40        and create = C_Create of {
41            argInit : block,
42            name : Atom.atom,
43            args : var list
44          }
45    
46    (* do we use this?
47        and iter = I_Range of {
48            rangeInit : block,
49            param : var,
50            lo : var,
51            hi : var
52          }
53    *)
54    
55        and strand = Strand of {
56          name : Atom.atom,          name : Atom.atom,
57          params : var list,          params : var list,
58          state : var list,          state : var list,
# Line 28  Line 60 
60          methods : method list          methods : method list
61        }        }
62    
63      and method = Method of Atom.atom * block      and method = Method of StrandUtil.method_name * block
64    
65      and block = Block of stmt list      and block = Block of stmt list
66    
67      and stmt      and stmt
68        = S_Assign of var * exp        = S_Var of var                            (* introduce an uninitialized local variable. *)
69                                                    (* These stmts are needed for the results of *)
70                                                    (* conditional expressions *)
71          | S_Assign of var * exp
72        | S_IfThenElse of var * block * block        | S_IfThenElse of var * block * block
73        | S_New of Atom.atom * var list        | S_New of Atom.atom * var list
74        | S_Die        | S_Die
75        | S_Stabilize        | S_Stabilize
76          | S_Return of var
77          | S_Print of var list
78    
79      and exp      and exp
80        = E_Var of var        = E_Var of var
# Line 45  Line 82 
82        | E_Tuple of var list        | E_Tuple of var list
83        | E_Apply of var * Types.meta_var list * var list * Types.ty        | E_Apply of var * Types.meta_var list * var list * Types.ty
84        | E_Cons of var list        | E_Cons of var list
85        | E_Input of string * var option        | E_Seq of var list
86        | E_Field of FieldDef.field_def        | E_Slice of var * var option list * Types.ty             (* tensor slicing *)
87          | E_Coerce of {srcTy : Types.ty, dstTy : Types.ty, x : var}
88      and create = C_Create of {        | E_LoadSeq of Types.ty * string
89          argInit : block,        | E_LoadImage of Types.ty * string * ImageInfo.info
         name : Atom.atom,  
         args : var list  
       }  
   
     and iter = I_Range of {  
         rangeInit : block,  
         param : var,  
         lo : var,  
         hi : var  
       }  
90    
91      fun typeOf (E_Var x) = Var.monoTypeOf x      fun typeOf (E_Var x) = Var.monoTypeOf x
92        | typeOf (E_Lit lit) = (case lit        | typeOf (E_Lit lit) = (case lit
# Line 70  Line 97 
97            (* end case *))            (* end case *))
98        | typeOf (E_Tuple _) = raise Fail "E_Tuple"        | typeOf (E_Tuple _) = raise Fail "E_Tuple"
99        | typeOf (E_Apply(_, _, _, ty)) = ty        | typeOf (E_Apply(_, _, _, ty)) = ty
100          | typeOf (E_Cons[]) = raise Fail "impossible empty E_Cons"
101        | typeOf (E_Cons(x::xs)) = let        | typeOf (E_Cons(x::xs)) = let
102            val d = List.length xs + 1            val d = List.length xs + 1
103            val ty = Var.monoTypeOf x            val ty = Var.monoTypeOf x
# Line 79  Line 107 
107                | _ => raise Fail "element of tensor construction not tensor"                | _ => raise Fail "element of tensor construction not tensor"
108              (* end case *)              (* end case *)
109            end            end
110        | typeOf (E_Cons[]) = raise Fail "impossible empty E_Cons"        | typeOf (E_Seq[]) = raise Fail "empty sequence not supported yet"
111          | typeOf (E_Seq(x::xs)) = let
112              val d = List.length xs + 1
113              val ty = Var.monoTypeOf x
114              in
115                Types.T_Sequence(ty, Types.DimConst d)
116              end
117          | typeOf (E_Slice(_, _, ty)) = ty
118          | typeOf (E_Coerce{dstTy, ...}) = dstTy
119          | typeOf (E_LoadSeq(ty, _)) = ty
120          | typeOf (E_LoadImage(ty, _, _)) = ty
121    
122    end    end

Legend:
Removed from v.221  
changed lines
  Added in v.2141

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