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

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