SCM Repository
Annotation of /branches/pure-cfg/src/compiler/tree-il/tree-il.sml
Parent Directory
|
Revision Log
Revision 624 -
(view)
(download)
Original Path: branches/pure-cfg/src/compiler/codegen/tree-il.sml
1 : | jhr | 529 | (* tree-il.sml |
2 : | * | ||
3 : | * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu) | ||
4 : | * All rights reserved. | ||
5 : | * | ||
6 : | * This representation restores the block structure and nested expression syntax | ||
7 : | * of the source language. | ||
8 : | *) | ||
9 : | |||
10 : | structure TreeIL = | ||
11 : | struct | ||
12 : | |||
13 : | structure Op = LowOps | ||
14 : | jhr | 531 | structure Ty = LowILTypes |
15 : | jhr | 529 | |
16 : | datatype program = Program of { | ||
17 : | globals : var list, | ||
18 : | jhr | 531 | globalInit : block, |
19 : | jhr | 624 | strands : strand list, |
20 : | initially : { | ||
21 : | isArray : bool, | ||
22 : | iterPrefix : block, | ||
23 : | iters : (var * exp * exp) list, | ||
24 : | createPrefix : block, | ||
25 : | strand : Atom.atom, | ||
26 : | args : exp list | ||
27 : | } | ||
28 : | jhr | 529 | } |
29 : | |||
30 : | and strand = Strand of { | ||
31 : | name : Atom.atom, | ||
32 : | params : var list, | ||
33 : | state : var list, | ||
34 : | jhr | 531 | stateInit : block, |
35 : | jhr | 529 | methods : method list |
36 : | } | ||
37 : | |||
38 : | and method = Method of { | ||
39 : | name : Atom.atom, | ||
40 : | jhr | 531 | body : block (* method body *) |
41 : | jhr | 529 | } |
42 : | |||
43 : | and block = Block of { | ||
44 : | locals : var list, | ||
45 : | body : stm list | ||
46 : | } | ||
47 : | |||
48 : | and stm | ||
49 : | = S_Comment of string list | ||
50 : | | S_Assign of var * exp | ||
51 : | jhr | 548 | | S_IfThen of exp * block |
52 : | | S_IfThenElse of exp * block * block | ||
53 : | jhr | 615 | | S_For of var * exp * exp * block (* limited for loop *) |
54 : | jhr | 548 | (* special Diderot forms *) |
55 : | jhr | 533 | | S_Cons of var * exp list (* tensor-value construction *) |
56 : | jhr | 548 | | S_LoadVoxels of var * int * exp |
57 : | jhr | 533 | | S_LoadImage of var * int * exp (* load image data *) |
58 : | | S_Input of var * string * exp option (* get input *) | ||
59 : | jhr | 563 | | S_Exit of exp list |
60 : | (* return functions for methods *) | ||
61 : | | S_Active of exp list | ||
62 : | | S_Stabilize of exp list | ||
63 : | jhr | 529 | | S_Die |
64 : | |||
65 : | and exp | ||
66 : | = E_Var of var | ||
67 : | | E_Lit of Literal.literal | ||
68 : | | E_Op of Op.rator * exp list | ||
69 : | |||
70 : | and var = V of { | ||
71 : | name : string, (* name (should be unique) *) | ||
72 : | id : Stamp.stamp, (* unique ID *) | ||
73 : | kind : var_kind, | ||
74 : | ty : Ty.ty (* type *) | ||
75 : | } | ||
76 : | |||
77 : | jhr | 531 | and var_kind |
78 : | jhr | 529 | = VK_Global (* global variable *) |
79 : | jhr | 538 | | VK_State of Atom.atom (* strand state variable *) |
80 : | jhr | 529 | | VK_Local (* includes strand parameters *) |
81 : | |||
82 : | jhr | 532 | structure Var : sig |
83 : | |||
84 : | val kind : var -> var_kind | ||
85 : | val name : var -> string | ||
86 : | val ty : var -> Ty.ty | ||
87 : | |||
88 : | structure Map : ORD_MAP where type Key.ord_key = var | ||
89 : | |||
90 : | end = struct | ||
91 : | fun kind (V{kind, ...}) = kind | ||
92 : | fun name (V{name, ...}) = name | ||
93 : | fun ty (V{ty, ...}) = ty | ||
94 : | local | ||
95 : | structure VarOrd = | ||
96 : | struct | ||
97 : | type ord_key = var | ||
98 : | fun compare (V{id=a, ...}, V{id=b, ...}) = Stamp.compare(a, b) | ||
99 : | end | ||
100 : | in | ||
101 : | structure Map = RedBlackMapFn (VarOrd) | ||
102 : | end (* local *) | ||
103 : | end | ||
104 : | |||
105 : | jhr | 529 | end |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |