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 171, Sat Jul 24 14:13:10 2010 UTC branches/vis12/src/compiler/simplify/simple.sml revision 2016, Tue Oct 9 03:22:30 2012 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 13  Line 15 
15    
16      datatype var = datatype AST.var      datatype var = datatype AST.var
17    
18      datatype program = Prog of {      datatype program = Program of {
19            inputs : (var * Types.ty Inputs.input) list,
20          globals : var list,          globals : var list,
21          globalInit : stmt,          globalInit : block,
22          actors : actor list          strands : strand list,
23          (* initialization *)          init : init                     (* block evaluates any vars used in init *)
24        }        }
25    
26      and actor = Actor of {      and init = Initially of {
27            isArray : bool,
28            rangeInit : block,
29            iters : {param : var, lo : var, hi : var} list,
30            create : create
31          }
32    
33        and create = C_Create of {
34            argInit : block,
35            name : Atom.atom,
36            args : var list
37          }
38    
39        and iter = I_Range of {
40            rangeInit : block,
41            param : var,
42            lo : var,
43            hi : var
44          }
45    
46        and strand = Strand of {
47            name : Atom.atom,
48          params : var list,          params : var list,
49          state : var list,          state : var list,
50          stateInit : stmt,          stateInit : block,
51          methods : method list          methods : method list
52        }        }
53    
54      and method      and method = Method of StrandUtil.method_name * block
55        = M_Method of Atom.atom * stmt  
56        and block = Block of stmt list
57    
58      and stmt      and stmt
59        = S_Block of stmt list        = S_Var of var                            (* introduce an uninitialized local variable. *)
60                                                    (* These stmts are needed for the results of *)
61                                                    (* conditional expressions *)
62        | S_Assign of var * exp        | S_Assign of var * exp
63        | S_IfThenElse of var * stmt * stmt        | S_IfThenElse of var * block * block
64        | S_New of Atom.atom * var list        | S_New of Atom.atom * var list
65        | S_Die        | S_Die
66        | S_Stabilize        | S_Stabilize
67          | S_Print of var list
68    
69      and exp      and exp
70        = E_Var of var        = E_Var of var
# Line 44  Line 72 
72        | E_Tuple of var list        | E_Tuple of var list
73        | E_Apply of var * Types.meta_var list * var list * Types.ty        | E_Apply of var * Types.meta_var list * var list * Types.ty
74        | E_Cons of var list        | E_Cons of var list
75          | E_Seq of var list
76      and create = C_Create of {        | E_Slice of var * var option list * Types.ty             (* tensor slicing *)
77          argInit : stmt,        | E_Coerce of {srcTy : Types.ty, dstTy : Types.ty, x : var}
         name : Atom.atom,  
         args : var list  
       }  
   
     and iter = I_Range of {  
         rangeInit : stmt,  
         param : var,  
         lo : var,  
         hi : var  
       }  
78    
79      fun typeOf (E_Var x) = Var.monoTypeOf x      fun typeOf (E_Var x) = Var.monoTypeOf x
80        | typeOf (E_Lit lit) = (case lit        | typeOf (E_Lit lit) = (case lit
# Line 67  Line 85 
85            (* end case *))            (* end case *))
86        | typeOf (E_Tuple _) = raise Fail "E_Tuple"        | typeOf (E_Tuple _) = raise Fail "E_Tuple"
87        | typeOf (E_Apply(_, _, _, ty)) = ty        | typeOf (E_Apply(_, _, _, ty)) = ty
88          | typeOf (E_Cons[]) = raise Fail "impossible empty E_Cons"
89        | typeOf (E_Cons(x::xs)) = let        | typeOf (E_Cons(x::xs)) = let
90            val d = List.length xs + 1            val d = List.length xs + 1
91            val ty = Var.monoTypeOf x            val ty = Var.monoTypeOf x
# Line 76  Line 95 
95                | _ => raise Fail "element of tensor construction not tensor"                | _ => raise Fail "element of tensor construction not tensor"
96              (* end case *)              (* end case *)
97            end            end
98        | typeOf (E_Cons[]) = raise Fail "impossible empty E_Cons"        | typeOf (E_Seq[]) = raise Fail "empty sequence not supported yet"
99          | typeOf (E_Seq(x::xs)) = let
100              val d = List.length xs + 1
101              val ty = Var.monoTypeOf x
102              in
103                Types.T_Sequence(ty, Types.DimConst d)
104              end
105          | typeOf (E_Slice(_, _, ty)) = ty
106          | typeOf (E_Coerce{dstTy, ...}) = dstTy
107    
108    end    end

Legend:
Removed from v.171  
changed lines
  Added in v.2016

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