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

SCM Repository

[smlnj] Diff of /sml/trunk/compiler/FLINT/cpsopt/etasplit.sml
ViewVC logotype

Diff of /sml/trunk/compiler/FLINT/cpsopt/etasplit.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4812, Wed Sep 12 21:56:57 2018 UTC revision 4813, Wed Sep 12 23:55:25 2018 UTC
# Line 1  Line 1 
1  (* Copyright 1996 by Bell Laboratories *)  (* etasplit.sml
2  (* cps/etasplit.sml *)   *
3     * COPYRIGHT (c) 2018 The Fellowship of SML/NJ (http://www.smlnj.org)
4  (*   * All rights reserved.
5     *
6   * Perform the eta-split transformation on cps expressions.  The   * Perform the eta-split transformation on cps expressions.  The
7   * purpose of the eta split transformation is to give two entry points   * purpose of the eta split transformation is to give two entry points
8   * to functions which both escape and which are called at known   * to functions which both escape and which are called at known
# Line 16  Line 17 
17   * continuations that were created for reasons of space complexity (as   * continuations that were created for reasons of space complexity (as
18   * the join of two branches, for example).  I doubt there are many   * the join of two branches, for example).  I doubt there are many
19   * continuations which both escape and have known calls. (Trevor Jim)   * continuations which both escape and have known calls. (Trevor Jim)
  *  
20   *)   *)
21    
22  signature ETASPLIT =  signature ETASPLIT = sig
23    sig val etasplit : {function: CPS.function,  
24                        table: LtyDef.lty IntHashTable.hash_table,      val etasplit : {
25                        click: string -> unit} -> CPS.function              function : CPS.function,
26                click : string -> unit
27              } -> CPS.function
28    
29    end (* signature ETASPLIT *)    end (* signature ETASPLIT *)
30    
31  functor EtaSplit(MachSpec : MACH_SPEC) : ETASPLIT =  functor EtaSplit(MachSpec : MACH_SPEC) : ETASPLIT =
# Line 35  Line 38 
38  fun sameName(x,VAR y) = LV.sameName(x,y)  fun sameName(x,VAR y) = LV.sameName(x,y)
39    | sameName _ = ()    | sameName _ = ()
40    
41  fun etasplit{function=(fkind,fvar,fargs,ctyl,cexp),  fun etasplit {function=(fkind,fvar,fargs,ctyl,cexp), click} =
              table=typtable,  
              click} =  
42  let  let
43    
44  val debug = !Control.CG.debugcps (* false *)  val debug = !Control.CG.debugcps (* false *)
45  fun debugprint s = if debug then Control.Print.say s else ()  fun debugprint s = if debug then Control.Print.say s else ()
46  fun debugflush() = if debug then Control.Print.flush() else ()  fun debugflush() = if debug then Control.Print.flush() else ()
 val rep_flag = MachSpec.representations  
 val type_flag = (!Control.CG.checkcps1) andalso rep_flag  
   
47    
48  exception SPLIT1  exception SPLIT1
49  fun getty v =  
50    if type_flag  fun copyLvar v = LV.dupLvar(v)
   then (IntHashTable.lookup typtable v) handle _ =>  
                 (Control.Print.say ("SPLIT1: Can't find the variable "^  
                             (Int.toString v)^" in the typtable ***** \n");  
                  raise SPLIT1)  
   else LtyExtern.ltc_void  
   
 fun addty(f,t) = if type_flag then IntHashTable.insert typtable (f,t) else ()  
 fun copyLvar v = let val x = LV.dupLvar(v)  
                   in (addty(x,getty v); x)  
                  end  
51    
52  local exception SPLIT2  local exception SPLIT2
53        val m : value IntHashTable.hash_table = IntHashTable.mkTable(32, SPLIT2)        val m : value IntHashTable.hash_table = IntHashTable.mkTable(32, SPLIT2)

Legend:
Removed from v.4812  
changed lines
  Added in v.4813

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