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/Semant/basics/inlinfo.sml
ViewVC logotype

Annotation of /sml/trunk/src/compiler/Semant/basics/inlinfo.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 772 - (view) (download)

1 : monnier 249 (* Copyright 1996 by Bell Laboratories *)
2 :     (* inlinfo.sml *)
3 :    
4 :     signature INL_INFO =
5 :     sig
6 :    
7 :     datatype inl_info
8 : blume 772 = INL_PRIM of PrimOp.primop * Types.ty
9 : monnier 249 (* | INL_LEXP of FLINT.prog * Types.ty option *)
10 : blume 772 | INL_PATH of Access.access * Types.ty option (* still used anywhere? *)
11 : monnier 249 | INL_STR of inl_info list
12 :     | INL_NO
13 :    
14 :     val prInfo : inl_info -> string
15 :     val selInfo : inl_info * int -> inl_info
16 :    
17 :     val isPrimInfo : inl_info -> bool
18 :     val isPrimCallcc : inl_info -> bool
19 :     val pureInfo : inl_info -> bool
20 :    
21 : blume 772 val mkPrimInfo : PrimOp.primop * Types.ty -> inl_info
22 : monnier 249 val mkAccInfo : Access.access * Types.ty option -> inl_info
23 :     val mkStrInfo : inl_info list -> inl_info
24 :    
25 :     val nullInfo : inl_info
26 :    
27 :     end (* signature INL_INFO *)
28 :    
29 :    
30 :     structure InlInfo : INL_INFO =
31 :     struct
32 :    
33 :     local structure A = Access
34 :     structure PO = PrimOp
35 :     structure T = Types
36 :     structure EM = ErrorMsg
37 :     in
38 :    
39 :     fun bug msg = EM.impossible("InlInfo: "^msg)
40 :    
41 :     (*
42 :     * inl_info: the information used for inter-module or intra-module
43 :     * inlining and specializations. Each access path is associated with
44 :     * specific inlining-information. INL_NO means that there is no specific
45 :     * information available so the dynamic access path must be used. INL_PRIM
46 :     * means the access is actually a built-in primops. INL_LEXP refers to
47 :     * an access whose implementation is memorized as an intermediate lambda
48 :     * expression lexp; the expression might be containing free variables, but
49 :     * they must have acc_paths of the form PATH(i1,...(PATH(i_n, EXTERN pid))).
50 :     * INL_PATH means the current access shares the inlining information with
51 :     * the one with acc_path. INL_STR means the current access is a module
52 :     * structure with proper inlining information for each of its components.
53 :     *)
54 :     datatype inl_info
55 : blume 772 = INL_PRIM of PO.primop * T.ty
56 : monnier 249 (*| INL_LEXP of FLINT.prog * T.ty option (* should be lty option *) *)
57 :     | INL_PATH of A.access * T.ty option
58 :     | INL_STR of inl_info list
59 :     | INL_NO
60 :    
61 :    
62 :     (****************************************************************************
63 :     * UTILITY FUNCTIONS FOR INL_INFO *
64 :     ****************************************************************************)
65 :    
66 :     (** printing an inl_info object *)
67 :     fun prInfo (INL_PRIM (p, _)) = PO.prPrimop p
68 :     (*| prInfo (INL_LEXP _) = "<InlLexp>" *)
69 :     | prInfo (INL_PATH (acc, _)) = A.prAcc(acc)
70 :     | prInfo (INL_STR []) = "{}"
71 :     | prInfo (INL_STR (a::r)) =
72 :     let val r' = foldr (fn (i,s) => ("," ^ (prInfo i) ^ s)) "}" r
73 :     in "{" ^ (prInfo a) ^ r'
74 :     end
75 :     | prInfo (INL_NO) = "<InlNo>"
76 :    
77 :    
78 :     (** selecting a component out of a structure info *)
79 :     fun selInfo (INL_STR sl, i) =
80 :     (List.nth(sl, i) handle Subscript => bug "Wrong field in INL_STR !")
81 :     | selInfo (INL_NO, i) = INL_NO
82 :     | selInfo _ = bug "Unexpected or un-implemented cases in selInfo"
83 :    
84 :     (** checking if it is a primop *)
85 :     fun isPrimInfo (INL_PRIM _) = true
86 :     | isPrimInfo _ = false
87 :    
88 :     (** checking if a particular primop captures the continuations *)
89 :     fun isPrimCallcc (INL_PRIM (PO.CALLCC, _)) = true
90 :     | isPrimCallcc (INL_PRIM (PO.CAPTURE, _)) = true
91 :     | isPrimCallcc _ = false
92 :    
93 :     (** checking if a particular primop can incur side-effects *)
94 :     fun pureInfo (INL_PRIM (PO.CAST, _)) = true
95 :     | pureInfo (INL_PRIM (p, _)) = false (* PO.purePrimop p *)
96 :     | pureInfo _ = false
97 :    
98 :     (** build a new primop info *)
99 :     fun mkPrimInfo x = INL_PRIM x
100 :    
101 :     (** build a new access info *)
102 :     fun mkAccInfo x = INL_PATH x
103 :    
104 :     (** build a new structure info *)
105 :     fun mkStrInfo x = INL_STR x
106 :    
107 :     val nullInfo = INL_NO
108 :    
109 :     end (* toplevel local *)
110 :     end (* structure InlInfo *)
111 :    
112 :    

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