Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/compiler/FLINT/flint/flint.sml
ViewVC logotype

Annotation of /sml/trunk/src/compiler/FLINT/flint/flint.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 251 - (view) (download)

1 : monnier 16 (* COPYRIGHT (c) 1997 YALE FLINT PROJECT *)
2 :     (* flint.sml *)
3 :    
4 :     structure FLINT : FLINT =
5 :     struct
6 :    
7 :     local structure A = Access (* should go away soon *)
8 :     structure LD = LtyDef
9 : monnier 45 structure LB = LtyBasic
10 : monnier 16 structure LV = LambdaVar
11 :     structure PO = PrimOp
12 :     structure S = Symbol
13 :     in
14 :    
15 :     type tkind = LD.tkind
16 :     type tyc = LD.tyc
17 :     type lty = LD.lty
18 : monnier 45
19 :     type tvar = LD.tvar
20 : monnier 16 type lvar = LV.lvar
21 :    
22 : monnier 45 type fflag = LD.fflag
23 :     type rflag = LD.rflag
24 :    
25 : monnier 184
26 :     (* what kind of inlining behavior is desired for the function *)
27 :     datatype ilhint
28 : monnier 202 = IH_SAFE (* only if trivially size-safe *)
29 :     | IH_ALWAYS (* inline whenever possible *)
30 : monnier 184 | IH_UNROLL (* only inline once within itself *)
31 : monnier 202 (* call-site dependent inlining:
32 :     * #1 < sum (map2 (fn (a,w) => (known a) * w) (actuals, #2) *)
33 :     | IH_MAYBE of int * int list
34 : monnier 184
35 :     (* what kind of recursive function (aka loop) is this *)
36 :     datatype loopkind
37 :     = LK_UNKNOWN (* something else *)
38 :     | LK_LOOP (* loop wrapped in a preheader *)
39 : monnier 199 | LK_TAIL (* properly tail-recursive *)
40 : monnier 184
41 :     (* calling convention *)
42 :     datatype cconv
43 :     = CC_FCT (* it's a functor *)
44 :     | CC_FUN of fflag (* it's a function *)
45 :    
46 : monnier 16 (** classifying various kinds of functions *)
47 : monnier 184 type fkind
48 :     = {inline: ilhint, (* when should it be inlined *)
49 :     known : bool, (* are all the call sites known *)
50 :     cconv : cconv, (* calling convention *)
51 :     isrec : (lty list * loopkind) option} (* is it recursive *)
52 : monnier 16
53 : monnier 220 (* additional attributes for type abstractions *)
54 :     type tfkind
55 :     = {inline: ilhint}
56 :    
57 : monnier 16 (** classifying various kinds of records *)
58 :     datatype rkind
59 : monnier 45 = RK_VECTOR of tyc (* vector: all elements have same type *)
60 :     | RK_STRUCT (* module: elements may be polymorphic *)
61 :     | RK_TUPLE of rflag (* tuple: all elements are monomorphic *)
62 : monnier 16
63 :     (*
64 :     * dcon records the name of the constructor (for debugging), the
65 : monnier 45 * corresponding conrep, and the flint type lty (which must be an
66 :     * arrow type).
67 : monnier 16 *)
68 :     type dcon = S.symbol * A.conrep * lty
69 :    
70 :     (*
71 :     * con: used to specify all possible switching statements. Efficient switch
72 :     * generation can be applied to DATAcon and INTcon. Otherwise, the switch is
73 :     * just a short-hand of the binary branch trees. Some of these instances
74 : monnier 45 * such as REALcon and VLENcon will go away soon.
75 : monnier 16 *)
76 :     datatype con
77 : monnier 45 = DATAcon of dcon * tyc list * lvar
78 : monnier 16 | INTcon of int (* should use InfInf.int *)
79 :     | INT32con of Int32.int
80 :     | WORDcon of word
81 :     | WORD32con of Word32.word
82 :     | REALcon of string
83 :     | STRINGcon of string
84 :     | VLENcon of int
85 :    
86 :     (** simple values, including variables and static constants. *)
87 :     datatype value
88 :     = VAR of lvar
89 :     | INT of int (* should use InfInf.int *)
90 :     | INT32 of Int32.int
91 :     | WORD of word
92 :     | WORD32 of Word32.word
93 :     | REAL of string
94 :     | STRING of string
95 :    
96 :     (** the definitions of the lambda expressions *)
97 :     datatype lexp
98 :     = RET of value list
99 :     | LET of lvar list * lexp * lexp
100 :    
101 :     | FIX of fundec list * lexp
102 : monnier 45 | APP of value * value list
103 : monnier 16
104 : monnier 45 | TFN of tfundec * lexp
105 : monnier 16 | TAPP of value * tyc list
106 :    
107 :     | SWITCH of value * A.consig * (con * lexp) list * lexp option
108 : monnier 45 | CON of dcon * tyc list * value * lvar * lexp
109 : monnier 16
110 :     | RECORD of rkind * value list * lvar * lexp
111 :     | SELECT of value * int * lvar * lexp (* add rkind ? *)
112 :    
113 :     | RAISE of value * lty list
114 :     | HANDLE of lexp * value
115 :    
116 : monnier 45 | BRANCH of primop * value list * lexp * lexp
117 : monnier 16 | PRIMOP of primop * value list * lvar * lexp
118 :    
119 :     withtype fundec = fkind * lvar * (lvar * lty) list * lexp
120 : monnier 220 and tfundec = tfkind * lvar * (tvar * tkind) list * lexp
121 : monnier 16 and dict = {default: lvar, table: (tyc list * lvar) list}
122 : monnier 45 and primop = dict option * PO.primop * lty * tyc list
123 :     (* Invariant: primop's lty is always fully closed *)
124 : monnier 16
125 : monnier 45 type prog = fundec (* was "lvar * lty * lexp" *)
126 : monnier 16
127 :     end (* local *)
128 :     end (* structure FLINT *)

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