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

revision 3369, Mon Nov 2 19:38:34 2015 UTC revision 3540, Mon Jan 4 18:03:22 2016 UTC
# Line 17  Line 17 
17      structure L=LiftEin      structure L=LiftEin
18      in      in
19    
20        val liftflag=true
21        val splitflag=true
22        val splitlimit=NONE
23      val testinitial=0      val testinitial=0
24      val testing=0      val testing=0
25      fun testp n=(case testing      fun testp n=(case testing
# Line 30  Line 33 
33      fun useCount (HighIL.V{useCnt, ...}) = !useCnt      fun useCount (HighIL.V{useCnt, ...}) = !useCnt
34      fun expandEinOp (srcy,bind00)=let      fun expandEinOp (srcy,bind00)=let
35          (*val _=raise Fail"development branch- do not use"*)          (*val _=raise Fail"development branch- do not use"*)
36    
37          val star="************"          val star="************"
38          val _=("\n Start"^star)          val _=("\n Start"^star)
39          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]
# Line 37  Line 41 
41    
42    
43          (* ************* Sweep for 0's'*********** *)          (* ************* Sweep for 0's'*********** *)
44            val _ =testp["Pre Sweep\n",P.printbody body,"\n"]
45          val bodysweep=sweepEin.sweep body          val bodysweep=sweepEin.sweep body
46          val ein1=Ein.EIN{params=params, index=index, body=bodysweep}          val ein1=Ein.EIN{params=params, index=index, body=bodysweep}
47          val _=testp["Post Sweep\n",P.printbody bodysweep,"\n"]          val _=testp["Post Sweep\n",P.printbody bodysweep,"\n"]
# Line 46  Line 51 
51          val bind3 = (y,DstIL.EINAPP(SummationEin.main ein1,args))          val bind3 = (y,DstIL.EINAPP(SummationEin.main ein1,args))
52          val _ =testp["\n\n summation \n\n =>", toStringBind bind3]          val _ =testp["\n\n summation \n\n =>", toStringBind bind3]
53    
54  (* **************** lift no split ************* *)          (* **************** lift - split ************* *)
55  (*          val newbies5=  (case (splitflag,liftflag,splitlimit)
56   val (einapp1,e2)=L.testLift  bind3              of (true,false,NONE) => Split.splitEinApp bind3
57  val newbies5=e2@[einapp1]              (* **************** split phase ************* *)
58     val _ =  print("\n **** lift Length"^(Int.toString(length(e2))))              | (true,false,SOME limit) =>let
59  *)                  val _ = (String.concat["\nSPLit with limit",Int.toString(limit)])
60      (* **************** lift field phase ************* *)                  in Split.limitSplit(bind3,limit) end
61                | (true,true,SOME limit) =>  let
62                    (* **************** lift and split Limit ************* *)
63                    val (einapp1,e2a,fieldset)=L.testLift  bind3
64                    val _ = (String.concat["\nSPLit with limit",Int.toString(limit),"\n **** lift Length:",Int.toString(length(e2a))])
65    
66                   (* val t2=List.map (fn t=>Split.splitEinApp t) e2*)
67                    val t2=List.map (fn t =>Split.limitSplit2(t,limit,fieldset)) e2a
68                    val e2= List.foldr op@ [] t2
69                    val newbies4=Split.limitSplit2(einapp1,limit,fieldset)
70                    val _ = testp["\n split made pieces(",Int.toString(length(e2)-length(e2a)),") orig (", Int.toString(length(newbies4)),")"]
71                    in (e2@newbies4) end
72                | (true,true, NONE) => let
73                    (* **************** lift and split All ************* *)
74                    val (einapp1,e2a,_)=L.testLift  bind3
75                    val _ =  testp["\n **** lift Length"^(Int.toString(length(e2a)))]
76                    val e2= List.foldr op@ [] (List.map (fn t=>Split.splitEinApp t) e2a)
77                    val newbies4=Split.splitEinApp einapp1
78                    val _ = testp["\n split made pieces(",Int.toString(length(e2)-length(e2a)),") orig (", Int.toString(length(newbies4)),")"]
79                    in (e2@newbies4) end
80    
81  (*  (*
82                | (false,true,_) => let
83           val (einapp1,e2)=L.testLift  bind3           val (einapp1,e2)=L.testLift  bind3
84          val newbies5=  Split.iterAll2(einapp1,e2)                  val _ = ("\n **** lift Length"^(Int.toString(length(e2))))
85          val n =length(newbies5)                  in (e2@[einapp1]) end
86          val _ = if (n > 10) then print("\n **** SPLIT Length"^(Int.toString(n))) else print ""              |  (false,false,_)=>Split.splitEinApp bind3
   
87  *)  *)
88            (* end case *))
89          (* **************** split phase ************* *)          val _ = "************** TASH"
90            (**************** printing result ***************)
91          val (newbies5)= Split.splitEinApp(bind3,9)          val _ =testp["\n\n Returning \n\n =>",
         val _ =test0["\n\n Returning \n\n =>",  
92          String.concatWith",\n\t"(List.map toStringBind newbies5)]          String.concatWith",\n\t"(List.map toStringBind newbies5)]
93            val n =length(newbies5)
94            val _ = if (n > 10) then testp["\n **** SPLIT Length",Int.toString(n)] else 1
95           (* ************** ProbeEIN *********** *)           (* ************** ProbeEIN *********** *)
96          (*gives probeEIN the set. Could split into a sepearate step*)          (*gives probeEIN the set. Could split into a sepearate step*)
97          val fieldset= einSet.EinSet.empty          val fieldset= einVarSet.EinVarSet.empty
98            val varset= einVarSet.VarSet.empty
99          val isField = ref 0          val isField = ref 0
100          val isFieldR = ref 0          val isFieldR = ref 0
101          val isReplaced = ref 0          val isReplaced = ref 0
102          fun iter([],_)=[]          fun iter([],_,_)=[]
103           | iter(e1::es,fieldset)= let           | iter(e1::es,fieldset,varset)= let
104              val (e2,fieldset,isFieldt,isReplacedt) = ProbeEin.expandEinOp(e1,fieldset)              val (e2,fieldset,varset,isFieldt,isReplacedt) = ProbeEin.expandEinOp(e1,fieldset,varset)
105              val rtn=[e2]@(iter(es,fieldset))              val rtn=[e2]@(iter(es,fieldset,varset))
106              val isFieldRt=if ((isFieldt+isReplacedt)=2) then 1 else 0              val isFieldRt=if ((isFieldt+isReplacedt)=2) then 1 else 0
107              in (isField:=(!isField)+isFieldt;isReplaced:=(!isReplaced )+isReplacedt;              in (isField:=(!isField)+isFieldt;isReplaced:=(!isReplaced )+isReplacedt;
108              isFieldR:=(!isFieldR)+isFieldRt;rtn)              isFieldR:=(!isFieldR)+isFieldRt;rtn)
109              end              end
110          val code=iter(newbies5, fieldset)          val code=iter(newbies5, fieldset,varset)
111            val flatcode= List.foldr op@ [] code
112    
113          val n= List.length(code)          val n= List.length(code)
114            val m= List.length(flatcode)
115            val _ =(String.concat["\n",HighIL.Var.name srcy ," Pieces",Int.toString (m),"\n"])
116    
117            val _ = if (n>5)            val _ = if (n>5)
118           then  print(String.concat["\n\n",star,":Name:",HighIL.Var.name srcy ,            then  testp["\n",star,":Name:",HighIL.Var.name srcy ,
119              ":VarCount(",Int.toString(useCount srcy),")",              ":VarCount(",Int.toString(useCount srcy),")","\n\tPieces now: ",Int.toString (n),"flatcode",Int.toString (m),
                 "\n\t",star,"Pieces now: ",Int.toString (n),  
120              " Fields:",Int.toString(!isField)," isReplaced:",Int.toString(!isReplaced),              " Fields:",Int.toString(!isField)," isReplaced:",Int.toString(!isReplaced),
121              " Replaced_Fields:",Int.toString(!isFieldR)])              " Replaced_Fields:",Int.toString(!isFieldR)] else 1
             else  print""  
122    
123    
124          val flatcode= List.foldr op@ [] code          val flatcode= List.foldr op@ [] code
125          (*val _=List.map (fn(_,DstIL.EINAPP(e,_))=>checkEin.checkEIN e | _=> 1) flatcode*)  (*
126          val _=(star^"end")          val tbl0= einSet.EinSet.empty
127            fun getSet([],done,_,cnt)=(done,cnt)
128             | getSet((lhs,rhs)::es,done,opset,cnt)=let
129                    val (opset,var) = einSet.rtnVarN(opset,(lhs,rhs))
130                    in  (case var
131                        of NONE => getSet(es,done@[(lhs,rhs)], opset,cnt)
132                        | SOME v=> (("replacing"^DstIL.Var.toString(lhs));getSet(es,done@[(lhs,DstIL.VAR v)], opset,cnt+1))
133                        (*end case*))
134                    end
135            val _="creating set"
136            val (flatcode,cnt)=getSet(flatcode, [],tbl0,0)
137            val _ = " post creating set"
138            val n=length(flatcode)
139            val _ = (String.concat["\n Length: ",Int.toString n," Replaced: ", Int.toString cnt,"\n"])
140    *)
141          in          in
142              List.map (fn (y,rator)=> DstIL.ASSGN(y,rator)) flatcode              List.map (fn (y,rator)=> DstIL.ASSGN(y,rator)) flatcode
143          end          end

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

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