Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/charisee_dev/src/compiler/high-to-mid/handleEin.sml
ViewVC logotype

Diff of /branches/charisee_dev/src/compiler/high-to-mid/handleEin.sml

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

branches/charisee/src/compiler/high-to-mid/handleEin.sml revision 3260, Wed Sep 23 16:09:21 2015 UTC branches/charisee_dev/src/compiler/high-to-mid/handleEin.sml revision 3369, Mon Nov 2 19:38:34 2015 UTC
# Line 1  Line 1 
1  (* Expands probe ein  (* Expands probe ein
2   *   *
3   * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)   * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
4     *
5     * COPYRIGHT (c) 2015 The University of Chicago
6   * All rights reserved.   * All rights reserved.
7   *)   *)
8    
# Line 10  Line 12 
12    
13      structure E = Ein      structure E = Ein
14      structure DstIL = MidIL      structure DstIL = MidIL
     structure DstOp = MidOps  
15      structure P=Printer      structure P=Printer
     structure T=TransformEin  
16      structure MidToS=MidToString      structure MidToS=MidToString
17      structure DstV  = DstIL.Var      structure L=LiftEin
18      in      in
19    
20      val testinitial=0      val testinitial=0
# Line 26  Line 26 
26      fun test0 n=(case testinitial      fun test0 n=(case testinitial
27          of 0=>testp n          of 0=>testp n
28          | _ => (print(String.concat n);1))          | _ => (print(String.concat n);1))
29      fun toStringBind e= MidToString.toStringBind e      fun toStringBind e= MidToS.toStringBind e
30        fun useCount (HighIL.V{useCnt, ...}) = !useCnt
31      fun expandEinOp bind00=let      fun expandEinOp (srcy,bind00)=let
32            (*val _=raise Fail"development branch- do not use"*)
33          val star="************"          val star="************"
34            val _=("\n Start"^star)
35          val _ =test0[star,"\n Original EinApp",star,"\n\n","start get test",toStringBind bind00]          val _ =test0[star,"\n Original EinApp",star,"\n\n","start get test",toStringBind bind00]
36          val (y,einapp as DstIL.EINAPP(Ein.EIN{params, index, body},args))=bind00          val (y,einapp as DstIL.EINAPP(Ein.EIN{params, index, body},args))=bind00
37    
# Line 45  Line 46 
46          val bind3 = (y,DstIL.EINAPP(SummationEin.main ein1,args))          val bind3 = (y,DstIL.EINAPP(SummationEin.main ein1,args))
47          val _ =testp["\n\n summation \n\n =>", toStringBind bind3]          val _ =testp["\n\n summation \n\n =>", toStringBind bind3]
48    
49    (* **************** lift no split ************* *)
50    (*
51     val (einapp1,e2)=L.testLift  bind3
52    val newbies5=e2@[einapp1]
53       val _ =  print("\n **** lift Length"^(Int.toString(length(e2))))
54    *)
55        (* **************** lift field phase ************* *)
56    (*
57             val (einapp1,e2)=L.testLift  bind3
58            val newbies5=  Split.iterAll2(einapp1,e2)
59            val n =length(newbies5)
60            val _ = if (n > 10) then print("\n **** SPLIT Length"^(Int.toString(n))) else print ""
61    
62    *)
63    
64          (* **************** split phase ************* *)          (* **************** split phase ************* *)
         val (newbies5)= Split.splitEinApp bind3  
         val _ =testp["\n\n Returning \n\n =>",  
             String.concatWith",\n\t"(List.map toStringBind newbies5)]  
65    
66            val (newbies5)= Split.splitEinApp(bind3,9)
67            val _ =test0["\n\n Returning \n\n =>",
68            String.concatWith",\n\t"(List.map toStringBind newbies5)]
69    
70           (* ************** ProbeEIN *********** *)           (* ************** ProbeEIN *********** *)
         (*val code=List.map (fn e=>ProbeEin.expandEinOp e) (newbies5)*)  
   
71          (*gives probeEIN the set. Could split into a sepearate step*)          (*gives probeEIN the set. Could split into a sepearate step*)
72          val fieldset= einSet.EinSet.empty          val fieldset= einSet.EinSet.empty
73            val isField = ref 0
74            val isFieldR = ref 0
75            val isReplaced = ref 0
76          fun iter([],_)=[]          fun iter([],_)=[]
77           | iter(e1::es,fieldset)= let           | iter(e1::es,fieldset)= let
78              val (e2,fieldset) = ProbeEin.expandEinOp(e1,fieldset)              val (e2,fieldset,isFieldt,isReplacedt) = ProbeEin.expandEinOp(e1,fieldset)
79              in [e2]@(iter(es,fieldset))              val rtn=[e2]@(iter(es,fieldset))
80                val isFieldRt=if ((isFieldt+isReplacedt)=2) then 1 else 0
81                in (isField:=(!isField)+isFieldt;isReplaced:=(!isReplaced )+isReplacedt;
82                isFieldR:=(!isFieldR)+isFieldRt;rtn)
83              end              end
84          val code=iter(newbies5, fieldset)          val code=iter(newbies5, fieldset)
85          (*val _ =print(String.concat[  
86              "\n",star,"Number of pieces now: ",Int.toString (List.length(code))])          val n= List.length(code)
87          *)  
88              val _ = if (n>5)
89             then  print(String.concat["\n\n",star,":Name:",HighIL.Var.name srcy ,
90                ":VarCount(",Int.toString(useCount srcy),")",
91                    "\n\t",star,"Pieces now: ",Int.toString (n),
92                " Fields:",Int.toString(!isField)," isReplaced:",Int.toString(!isReplaced),
93                " Replaced_Fields:",Int.toString(!isFieldR)])
94                else  print""
95    
96    
97          val flatcode= List.foldr op@ [] code          val flatcode= List.foldr op@ [] code
98          (*val _=List.map (fn(_,DstIL.EINAPP(e,_))=>checkEin.checkEIN e | _=> 1) flatcode*)          (*val _=List.map (fn(_,DstIL.EINAPP(e,_))=>checkEin.checkEIN e | _=> 1) flatcode*)
99            val _=(star^"end")
100          in          in
101              List.map (fn (y,rator)=> DstIL.ASSGN(y,rator)) flatcode              List.map (fn (y,rator)=> DstIL.ASSGN(y,rator)) flatcode
102          end          end

Legend:
Removed from v.3260  
changed lines
  Added in v.3369

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