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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3489 - (view) (download)

1 : cchiw 2845 (* Expands probe ein
2 :     *
3 : jhr 3349 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     *
5 :     * COPYRIGHT (c) 2015 The University of Chicago
6 : cchiw 2845 * All rights reserved.
7 :     *)
8 :    
9 :     structure handleEin = struct
10 :    
11 :     local
12 :    
13 :     structure E = Ein
14 :     structure DstIL = MidIL
15 :     structure P=Printer
16 :     structure MidToS=MidToString
17 : cchiw 3459 structure L=LiftEin
18 : cchiw 2845 in
19 :    
20 : cchiw 3472 val liftflag=true
21 : cchiw 3459 val splitflag=true
22 : cchiw 3489 val splitlimit=SOME 2650
23 : cchiw 3459
24 : cchiw 3489 val testinitial=1
25 : cchiw 3259 val testing=0
26 : cchiw 2845 fun testp n=(case testing
27 :     of 0=> 1
28 :     | _ =>(print(String.concat n);1)
29 :     (*end case*))
30 : cchiw 3166 fun test0 n=(case testinitial
31 : cchiw 3203 of 0=>testp n
32 : cchiw 3166 | _ => (print(String.concat n);1))
33 : cchiw 3324 fun toStringBind e= MidToS.toStringBind e
34 : cchiw 3271 fun useCount (HighIL.V{useCnt, ...}) = !useCnt
35 :     fun expandEinOp (srcy,bind00)=let
36 : cchiw 3489 (*val _= raise Fail"development branch- do not use"*)
37 :    
38 : cchiw 3033 val star="************"
39 : cchiw 3415 val _= ("\n Start"^star)
40 : cchiw 3260 val _ =test0[star,"\n Original EinApp",star,"\n\n","start get test",toStringBind bind00]
41 : cchiw 3203 val (y,einapp as DstIL.EINAPP(Ein.EIN{params, index, body},args))=bind00
42 : cchiw 3166
43 : cchiw 3033
44 :     (* ************* Sweep for 0's'*********** *)
45 : cchiw 3441 val _ =testp["Pre Sweep\n",P.printbody body,"\n"]
46 : cchiw 3203 val bodysweep=sweepEin.sweep body
47 : cchiw 3033 val ein1=Ein.EIN{params=params, index=index, body=bodysweep}
48 : cchiw 3441 val _ =testp["Post Sweep\n",P.printbody bodysweep,"\n"]
49 : cchiw 3033
50 :    
51 : cchiw 3203 (* ************** distribute and push Summation*********** *)
52 :     val bind3 = (y,DstIL.EINAPP(SummationEin.main ein1,args))
53 : cchiw 3260 val _ =testp["\n\n summation \n\n =>", toStringBind bind3]
54 : cchiw 3033
55 : cchiw 3472 (* **************** lift - split ************* *)
56 : cchiw 3459 val newbies5= (case (splitflag,liftflag,splitlimit)
57 : cchiw 3472 of (true,false,NONE) => Split.splitEinApp bind3
58 :     (* **************** split phase ************* *)
59 :     | (true,false,SOME limit) =>let
60 :     val _ =print (String.concat["\nSPLit with limit",Int.toString(limit)])
61 :     in Split.limitSplit(bind3,limit) end
62 : cchiw 3459 | (true,true,SOME limit) => let
63 :     (* **************** lift and split Limit ************* *)
64 :     val (einapp1,e2)=L.testLift bind3
65 :     val _ =print (String.concat["\nSPLit with limit",Int.toString(limit),"\n **** lift Length:",Int.toString(length(e2))])
66 : cchiw 3472 val newbies4=Split.limitSplit(einapp1,limit)
67 : cchiw 3459 in (e2@newbies4) end
68 :     | (true,true, NONE) => let
69 :     (* **************** lift and split All ************* *)
70 :     val (einapp1,e2)=L.testLift bind3
71 :     val _ = testp["\n **** lift Length"^(Int.toString(length(e2)))]
72 :     val newbies4=Split.splitEinApp einapp1
73 :     in (e2@newbies4) end
74 :     | (false,true,_) => let
75 :     val (einapp1,e2)=L.testLift bind3
76 :     val _ = print("\n **** lift Length"^(Int.toString(length(e2))))
77 :     in (e2@[einapp1]) end
78 :     | (false,false,_)=>Split.splitEinApp bind3
79 :     (* end case *))
80 : cchiw 3472 val _ =print"************** TASH"
81 : cchiw 3415 (**************** printing result ***************)
82 :     val _ =testp["\n\n Returning \n\n =>",
83 : cchiw 3344 String.concatWith",\n\t"(List.map toStringBind newbies5)]
84 : cchiw 3415 val n =length(newbies5)
85 : cchiw 3459 val _ = if (n > 10) then print(String.concat["\n **** SPLIT Length",Int.toString(n)]) else print ""
86 : cchiw 3166 (* ************** ProbeEIN *********** *)
87 : cchiw 3189 (*gives probeEIN the set. Could split into a sepearate step*)
88 : cchiw 3174 val fieldset= einSet.EinSet.empty
89 : cchiw 3271 val isField = ref 0
90 :     val isFieldR = ref 0
91 :     val isReplaced = ref 0
92 : cchiw 3174 fun iter([],_)=[]
93 :     | iter(e1::es,fieldset)= let
94 : cchiw 3271 val (e2,fieldset,isFieldt,isReplacedt) = ProbeEin.expandEinOp(e1,fieldset)
95 :     val rtn=[e2]@(iter(es,fieldset))
96 :     val isFieldRt=if ((isFieldt+isReplacedt)=2) then 1 else 0
97 :     in (isField:=(!isField)+isFieldt;isReplaced:=(!isReplaced )+isReplacedt;
98 :     isFieldR:=(!isFieldR)+isFieldRt;rtn)
99 :     end
100 : cchiw 3174 val code=iter(newbies5, fieldset)
101 : cchiw 3271
102 :     val n= List.length(code)
103 : cchiw 3441 val _ =testp[HighIL.Var.name srcy ," Pieces",Int.toString (n),"\n"]
104 : cchiw 3415 (*
105 : cchiw 3271 val _ = if (n>5)
106 : cchiw 3415 then print(String.concat["\n",star,":Name:",HighIL.Var.name srcy ,
107 :     ":VarCount(",Int.toString(useCount srcy),")","Pieces now: ",Int.toString (n),
108 : cchiw 3271 " Fields:",Int.toString(!isField)," isReplaced:",Int.toString(!isReplaced),
109 : cchiw 3369 " Replaced_Fields:",Int.toString(!isFieldR)])
110 : cchiw 3383 else print ""
111 : cchiw 3415 *)
112 :     val flatcode= List.foldr op@ [] code
113 : cchiw 3271
114 : cchiw 3369
115 : cchiw 3048 (*val _=List.map (fn(_,DstIL.EINAPP(e,_))=>checkEin.checkEIN e | _=> 1) flatcode*)
116 : cchiw 3344 val _=(star^"end")
117 : cchiw 3033 in
118 :     List.map (fn (y,rator)=> DstIL.ASSGN(y,rator)) flatcode
119 :     end
120 :    
121 : cchiw 2845 end; (* local *)
122 :    
123 :     end (* local *)

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